bitops-plugins / cloudformation

1 stars 1 forks source link

Verify that AWS account is present #3

Closed PhillypHenning closed 1 year ago

PhillypHenning commented 2 years ago

There needs to be a check made that verifies that the plugin has all appropriate parts including an AWS profile.

The below error results from having empty AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. A more meaningful message would be helpful.

~#~#~#~DEPLOYING OPS REPO [cloudformation] SUCCESSFULLY COMPLETED~#~#~#~
2022-10-03 18:16:48,852 root         DEBUG 
Welcome to the CloudFormation BitOps plugin!
Deploying cloudformation... cloudformation - Found BitOps config
All dependent plugins found. Continuing with deployment..
cd cloudformation Root: /tmp/tmppqh6ucas/Dev/cloudformation
Running Cloudformation Template Validation
Running Cloudformation Deploy Stack
Checking if stack exists ...
STACK_EXISTS_OUTPUT Unable to locate credentials. You can configure credentials by running "aws configure".

Stack does not exist, creating ...
create-stack
Parameters file doesn't exist...
Waiting on cloudformation stack BitOps-Demo create-stack completion...
Finished cloudfromation action create-stack successfully !!!
arm4b commented 1 year ago

From the message here the issue to me looks like that the script continues its work, even if the child bash script reported an issue with the credentials:

Running Cloudformation Deploy Stack
Checking if stack exists ...
STACK_EXISTS_OUTPUT Unable to locate credentials. You can configure credentials by running "aws configure".
# NOTE: ^^ it should `exit 1` here

Stack does not exist, creating ...
...
Finished cloudfromation action create-stack successfully !!!

The check for existence of AWS credentials in https://github.com/bitops-plugins/cloudformation/pull/11 is nice, but what if the credentials provided are invalid? We'll get the same results and the problem would be fixed only partially.

The root cause might be that we're missing bubbling up the original exit code in the script. It should fail from running aws.