You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Is it possible to use Bitbucket pipes to create cloudformation stacks on AWS and pass the results for processing in next steps ? This was possible in bamboo with Tasks for AWS.
script: - pipe: atlassian/aws-cloudformation-deploy:0.16.0 variables: AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION: 'us-east-1' STACK_NAME: 'my-stack-name' TEMPLATE: 'https://s3.amazonaws.com/cfn-deploy-pipe/cfn-template.json' CAPABILITIES: ['CAPABILITY_IAM', 'CAPABILITY_AUTO_EXPAND'] WAIT: 'true' WAIT_INTERVAL: 60 OUTPUTS_FILENAME: 'outputs' artifacts: - outputs.json
outputs.json sample data:
"Description": "Table name of the newly created DynamoDB table"
Would you be able to show an example of how the OutputValue would be used in a subsequent pipe?
I'm writing the outputs as an artifact as shown above and then I need the value to pass to another pipe (atlassian/aws-cloudfront-invalidate) but it needs to be parsed e.g.
$(cat outputs.json | jq -r '.Outputs | select(.OutputKey == "DistributionId") | .OutputValue')
I'm unable to run arbitrary code in the aws-cloudfront-invalidate pipe and if I do it as another command in the same step, then any env vars are lost.
@Darren Mansell hi. I do not understand why any env vars are lost.
Try example below and if you have issues with it, please describe them with details:
script: - pipe: atlassian/aws-cloudformation-deploy:0.19.0 variables: AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION: 'us-east-1' STACK_NAME: 'my-stack-name' TEMPLATE: 'https://s3.amazonaws.com/cfn-deploy-pipe/cfn-template.json' CAPABILITIES: ['CAPABILITY_IAM', 'CAPABILITY_AUTO_EXPAND'] WAIT: 'true' WAIT_INTERVAL: 60 OUTPUTS_FILENAME: 'outputs'
- DISTRIBUTION_ID=$(cat outputs.json | jq -r '.Outputs | select(.OutputKey == "TableName") | .OutputValue')
- pipe: atlassian/aws-cloudfront-invalidate:0.9.0
@Sam Ware hi. We added this feature as a task to our backlog, so the process when feature goes from tickets to our tasks passed. Now you should wait when this feature will become available if our team will find an option of how to implement this.
The Tasks for AWS (Bamboo) app @Neethu Philip is referring to supports Injecting task configuration via Bamboo variables, and "variables are automatically defined from AWS resources affected by a task".
So the ask here is not about the raw API response for create-stack, update-stack, rather about the outcome of this API operation, which depends on the resources provisioned by the CloudFormation template, and specifically which Outputs are defined within that template for reuse (so this is up to the template author):
Outputssection declares output values that you can import into other stacks (to create cross-stack references), return in response (to describe stack calls), or view on the AWS CloudFormation console. For example, you can output the S3 bucket name for a stack to make the bucket easier to find.
Accordingly, you would need to use the describe_stacks API to await the stack operation to succeed, and then pass on all values in the Outputs array to the next pipeline steps in a suitable fashion.
You can see an example within the Variables section of the CloudFormation task (abbreviated here) - the stack at hand provisioned an SQS queue and has outputs for the SQS queue URL and ARN:
Stack 'SampleStack-TAWS-IT230-CFN2-24' generated 2 outputs:
... SampleStack-TAWS-IT230-CFN2-24.outputs: QueueURL;QueueARN
... SampleStack-TAWS-IT230-CFN2-24.outputs.QueueURL: https://sqs.us-east-1.amazonaws.com/309600995652/Bamboo-24
... SampleStack-TAWS-IT230-CFN2-24.outputs.QueueARN: arn:aws:sqs:us-east-1:309600995652:Bamboo-24