Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a Deployment Variable Into pipe:aws-sam-deploy

William Francis March 18, 2025

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

2 answers

0 votes
William Francis March 20, 2025

 

 

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

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2025

Hi @William Francis 

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)

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events