Hi, I would like to leverage deployment variables in my pipeline. The deployment variables would set things like --template-file=templates/deploytemplate.yml --stack-name stack_version_XYZ and --parameter-overrides Environment=production. This would let me reuse this block of code several times by only changing the deployment variable.
What I have tried is setting a deployment variable AWS_DEPLOY_OPTIONS to
["--template-file","templates/deploytemplate.yml","--stack-name","stack_version_XYZ"]
And used it here
- step: &deploy-cloudformation
name: Deploy to Cloudformation
oidc: true
script:
- pipe: atlassian/aws-sam-deploy:2.4.1
variables:
AWS_DEFAULT_REGION: $AWS_REGION
AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
EXTRA_OPTIONS_DEPLOY: $AWS_DEPLOY_OPTIONS
This does not work, I can see that none of the extra options get passed in, confirmed by this line in the output:
INFO: ['sam', 'deploy', '--no-confirm-changeset', '--no-fail-on-empty-changeset']
I expect the reason this is not working is because the deployment variable is stored as a string, not the list of strings that aws-sam-deploy expects
From https://bitbucket.org/atlassian/aws-sam-deploy/src/master/
Options you can provide for sam
deploy
command in format['--option1=value1', '--option2', 'value2']
.
Is there string/variable manipulation I can do in the pipeline to get this to work?
Something like
DEPLOY = ['${AWS_DEPLOY_OPTIONS}']
or
DEPLOY = ['--template-file',$TEMPLATE_LOCATION,...etc ]
I would like to use the pipeline because it handles the OIDC for me, I tried essentially writing what aws-sam-deploy does for myself, but I had issues getting the authentication to work with OIDC
Hey Ben, this is the first time I'm trying this.
I ended up using this as a solution directly in the pipe options:
EXTRA_OPTIONS_DEPLOY: ["--stack-name",$CLOUD_STACKNAME,"--template-file",$TEMPLATE_FILELOCATION,"--region",$AWS_REGION,"--parameter-overrides",$CLOUD_PARAMETERS,"--capabilities",$CLOUD_CAPABILITY]
It will require code changes to my templates if I want to introduce a new option, which I was trying to avoid, but it does tick the box of making the code block very reusable with deployment variables
Can you try to add those arguments outside of a variable and let me know if it completes?
EXTRA_OPTIONS_DEPLOY: 'sam', 'deploy', '--no-confirm-changeset', '--no-fail-on-empty-changeset'
I'd also like to know what you're seeing in the output with debugging enabled:
DEBUG: 'true'
Also - was this working before and now is not? Or is this the first time you're trying this?
Cheers!
- Ben (Bitbucket Cloud Support)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.