Jiew Meng
Jiew Meng

Reputation: 88367

How can my CodeBuild in a CodePipeline resolve resources created by the previous CloudFormation step?

I have setup my CodePipeline something like:

  1. Source: Github
  2. CodeBuild: Package SAM application (CloudFormation resources like DB)
  3. Deploy CloudFormation: Does the create & execute changesets
  4. CodeBuild: I want to run DB migrations for the DB created by CloudFormation ... but how do I get it ... CodeBuild does not support parameters from my Pipeline

Maybe I am creating my pipeline wrong?

Upvotes: 0

Views: 244

Answers (2)

Maybe in the step 3. You setup your cloudformation in this way:

1- create the database...Export as an output the name of the database

Outputs:
    DataBaseName:
        Description: "Name of the Database"
        Value: !Ref DataBaseName

2- In the codebuild use the Boto3 and use the Describe Stacks and get the output (the name of the database and another information about it), now you could take advangate of Python in your codebuild and start the migration usign Boto3.

response = client.describe_stacks(
    StackName='string',
    NextToken='string'
)

Upvotes: 0

TimB
TimB

Reputation: 1597

The CloudFormation action can output stack parameters, but currently the CodeBuild action in CodePipeline can't accept both a code artifact and an artifact with CloudFormation outputs.

For now I'd call aws cloudformation describe-stacks from the CLI inside your build script to retrieve the DB information from your CloudFormation stacks.

Upvotes: 1

Related Questions