sparse-intern-71089
08/28/2020, 5:06 PMlemon-agent-27707
08/28/2020, 5:09 PMbillowy-army-68599
quaint-egg-65511
08/28/2020, 5:43 PMpulumi stack init and commit.
With terraform and terragrunt we don't interact with the state manually, we just commit and the CI runs.
There is no distinction between first run and any other runsquaint-egg-65511
08/28/2020, 5:45 PMechoing-breakfast-73834
08/28/2020, 5:47 PMpulumi login
• Run pulumi stack select --create "$ORGANIZATION/$PROJECT_NAME/$STACK_NAME"
• Create a config file `Pulumi.$STACK_NAME.yaml``, and edit it with yq
• Run pulumi preview --config-file "Pulumi.$STACK_NAME.yaml"quaint-egg-65511
08/28/2020, 5:47 PMcd environments/dev
terragrunt apply-all
And all modules are applied recursively with dependency resolutionechoing-breakfast-73834
08/28/2020, 5:49 PMpulumi stack select --create <stackname> part handles creation, and yq handles setting up the config. Pulumi has a command for setting config values but there's some reason I didn't use it when I set things up, can't remember now what it wasquaint-egg-65511
08/28/2020, 5:50 PMechoing-breakfast-73834
08/28/2020, 5:53 PMechoing-breakfast-73834
08/28/2020, 5:54 PMconfig:
aws:region: us-east-2
The only reason why aws:region is in there is because IIRC I put it there - no other values i.e. encryption keysfast-dinner-32080
08/28/2020, 5:59 PMpulumi login
pulumi plugin install
pulumi stack select ${STACK_NAME}
pulumi preview --diff
pulumi up --yes --skip-previewquaint-egg-65511
08/28/2020, 6:01 PMechoing-breakfast-73834
08/28/2020, 6:01 PMfast-dinner-32080
08/28/2020, 6:01 PMfast-dinner-32080
08/28/2020, 6:02 PMquaint-egg-65511
08/28/2020, 6:02 PMquaint-egg-65511
08/28/2020, 6:02 PMfast-dinner-32080
08/28/2020, 6:03 PMquaint-egg-65511
08/28/2020, 6:03 PMfast-dinner-32080
08/28/2020, 6:03 PMfast-dinner-32080
08/28/2020, 6:03 PMquaint-egg-65511
08/28/2020, 6:04 PMfast-dinner-32080
08/28/2020, 6:05 PMhundreds-musician-51496
08/28/2020, 6:05 PMpulumi -s <stack name> init and ignore the error if the stack exists. As for the pulum.*.yaml file, you can actually set all configuration values via command line options (pulumi up -c key=value).hundreds-musician-51496
08/28/2020, 6:05 PMhundreds-musician-51496
08/28/2020, 6:06 PMpulumi up had a create-stack flag but it doesn't 🤷fast-dinner-32080
08/28/2020, 6:06 PMfast-dinner-32080
08/28/2020, 6:06 PMfast-dinner-32080
08/28/2020, 6:07 PMfast-dinner-32080
08/28/2020, 6:07 PMechoing-breakfast-73834
08/28/2020, 6:07 PMechoing-breakfast-73834
08/28/2020, 6:08 PMquaint-egg-65511
08/28/2020, 6:37 PMquaint-egg-65511
08/28/2020, 6:37 PMbefore_script:
- python -V
- poetry -V
- pulumi version
- pulumi login --cloud-url <s3://my-pulumi-state>
- poetry install
preview.nprd:
tags:
- pulumi
image: $PULUMI_IMAGE
stage: preview
script:
- pulumi stack select -c my-service.common -C ./my-service --secrets-provider=$PULUMI_SECRETS_KMS
- pulumi preview --non-interactive -C ./my-service --diff
rules:
...quaint-egg-65511
08/28/2020, 6:39 PMquaint-egg-65511
08/28/2020, 6:40 PMplan.nprd:
tags:
- terragrunt
stage: plan
variables:
<<: *nprd-variables
script:
- cd workspaces/nprd
- terragrunt plan-all --terragrunt-non-interactive
rules:
....quaint-egg-65511
08/28/2020, 6:41 PMquaint-egg-65511
08/28/2020, 6:45 PM--secrets-provider during pulumi stack init it will add some kind of encryption(salt|key) to the Pulumi.<stack>.yml file.
If this happens during CI (as you can see I use stack select --create) I will lose that edit and I don’t know if it is important or not because is not documentedbillowy-army-68599
stack init component, if you have a Pulumi.<stack>.yaml in your repo you can do pulumi stack up -s <stack> there's no need to run initquaint-egg-65511
08/28/2020, 6:56 PMquaint-egg-65511
08/28/2020, 6:57 PMPulumi.<stack>.yaml i have it before the CI runs! but we just put our stack configsquaint-egg-65511
08/28/2020, 6:58 PMencryptedkey added to it when you run stack init or stack select -c?billowy-army-68599
mkdir -p prod/{app,vpc,mysql}
touch prod/{app,vpc,mysql}/terragrunt.hcl
with pulumi all you have to do is pulumi stack init --secretes-provider=fooquaint-egg-65511
08/28/2020, 7:06 PMquaint-egg-65511
08/28/2020, 7:07 PM{
"version": 3,
"checkpoint": {
"stack": "my-service.common"
}billowy-army-68599
if you are a developer, you don’t need access to KMSthis is because terraform stores all values in its state in plaintext, which we don't. If you're doing a stack init, you need access to do
encrypt on the key, you don't need access to decrypt though, which should be acceptable?
or worse to the state storage to create a PR,the native terraform way of working (ie with workspaces) does need this, your point is valid with regards to terragrunt though. Is the main reason you're restricting access to the pulumi state because you don't want your devs to be able to edit things?
billowy-army-68599
I’m talking about state storage edits because when you init a stack you MUST be logged to a backend and it will do some bootstrap write to the state storagea stack init is very similar to a
terraform init - our stacks have different state storage, terraform stores all its configuration in one big state file unless you're using workspacesbillowy-army-68599
kms:Encrypt permissions for the KMS key and write permission to the state and it should functionally do the same thingbillowy-army-68599
billowy-army-68599
quaint-egg-65511
08/28/2020, 7:30 PM