aws-samples / amazon-mwaa-examples

Amazon Managed Workflows for Apache Airflow (MWAA) Examples repository contains example DAGs, requirements.txt, plugins, and CloudFormation templates focused on Amazon MWAA.
MIT No Attribution
97 stars 54 forks source link

start-stop-mwaa-environment - AWS_REGION env var needed to deploy outside of us-east-1 #73

Open mvitale-kensu opened 1 month ago

mvitale-kensu commented 1 month ago

Hello guys, I was testing the start-stop-mwaa-environment project for our MWAA in eu-west-3. I just wanted to let you know, that at least in my case, to successfully run the npm run deploy step I had to set this env var:

export AWS_REGION=eu-west-3

Without this variable npm run deploy would output this warning (see the -us-east-1):

current credentials could not be used to assume 'arn:aws:iam::*****:role/cdk-hnb659fds-deploy-role-*****-us-east-1', but are for the right account. Proceeding anyway.

And then errors out with:

mwaa-pause-resume-airflow-internal: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)

After setting:

export AWS_REGION=eu-west-3

It worked perfectly. Maybe is something that will be useful to have in the readme.

We are on airflow 2.7.2 and I am using the latest code of this project available in main.

crupakheti commented 1 month ago

Hey @mvitale-kensu, the solution expects that you set CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION env variables. See here for details: https://github.com/aws-samples/amazon-mwaa-examples/tree/main/usecases/start-stop-mwaa-environment#1-create-a-env-file. Were these env variables not set when you deployed?

mvitale-kensu commented 1 month ago

Hey @crupakheti, Yes CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION were set in the .env file but it was not enough. I've also tried to export them in the shell (with export CDK_DEFAULT_ACCOUNT=...) but still, it was not working.

Only after running export AWS_REGION=eu-west-3 the deployment worked fine.

crupakheti commented 1 month ago

Thank you, @mvitale-kensu! Did this error occur when you ran cdk bootstrap or when you ran npm run deploy?

mvitale-kensu commented 1 month ago

The error occurs when running npm run deploy No issues with cdk bootstrap