Hi Folks, I am trying to initialize a stack using ...
# general
b
Hi Folks, I am trying to initialize a stack using
pulumi stack init --secrets-provider="<awskms://alias/kms?region=us-west-2>" --stack org-name/stack-name
but getting
error: organization name must be 'organization'
can anyone explain what's causing this error?
f
Hi @busy-toothbrush-90194 ! I have not seen this error before, but I will see if I can help you get it resolved. Would you mind sharing which version of Pulumi you're on? Also as a quick sanity check, if you run the command without the
--secrets-provider
flag, does it still give the same error?
b
Let me try
my pulumi version is
v3.82.0
I am trying this with aws s3 backend
f
The current version is
v3.92.0
. I would recommend updating Pulumi in your environment to start and try again. If you still get the same error, then we'd probably have to look into your S3 backend configuration I'm thinking
b
Do I need to specify the default org when I do pulumi login s3://<backend-name>
Copy code
--default-org string   A default org to associate with the login. Please note, currently, only the managed and self-hosted backends support organizations
p
anything that is not cloud has this. instead of <orgname>/<project>/<stackname> use organization/<project>/<stackname>
b
AWS s3 falls in the self hosted backend category I assume.
So we can't set the organization to any values other than
organization
with non pulumi cloud backend?
p
i think so
b
Okay, in my case this changes the name of the stack with pulumi cloud it is
org-name/stack-name
but with s3 it is just the
stack-name
. In s3 realm org name won't be as relevant as in Pulumi cloud but it would have been nice to keep the stack name the same post migration.
Anyways thanks for the help Roderik & Torian.
p
in case this helps, this is my migration script • migrates stacks with staging- in the name • fixes a stack reference that also moved to s3 • does not break the original cloud stack in case i mess up
Copy code
#!/bin/bash -x

export PULUMI_ACCESS_TOKEN="pul-xxx"
export PULUMI_CONFIG_PASSPHRASE=xxx

rm -Rf Pulumi.yaml Pulumi.*.yaml
echo "name: bpaas" > Pulumi.yaml
echo "runtime: nodejs" >> Pulumi.yaml
pulumi logout
pulumi login
STACKS=$(pulumi stack ls -j | jq -r ".[].name" | sed "s/settlemint\///" | grep 'staging-')
while read -r stack; do
  echo "Migrating stack ${stack}"
  pulumi logout
  pulumi login
  pulumi stack select settlemint/bpaas/${stack}
  pulumi stack change-secrets-provider "<awskms://alias/xxx-xxx-xxx?region=eu-central-1>"
  pulumi stack export --show-secrets --file ${stack}.json
  pulumi stack change-secrets-provider default
  pulumi logout
  pulumi login '<s3://xxx-xxx-xxx?region=eu-central-1>'
  pulumi stack init ${stack} || pulumi stack select organization/bpaas/${stack}
  cat ${stack}.json | sed 's/settlemint\/bpaas-clusters/organization\/bpaas-clusters/g' > ${stack}-replaced.json
  pulumi stack import --file ${stack}-replaced.json
  pulumi refresh --yes
done <<< "$STACKS"
b
Thanks a lot for sharing this, I am doing something similar.
We are facing issues with cross-stack reference when one stack is moved but other is not? Did you also have this issue by any chance? if so how did you approach this?
p
i moved the base stacks first, but left them on cloud too (k8s clusters where i only use the kubeconfig from) and then i move the using stacks