I have a CodePipeline-based project. I am attempting to pass a parameter generated at build time in a CodeBuild stage to an ApplicationStage deployment in CloudFormation.
My CDK version is 1.114.0.
Code:
// Pipeline
const pipeline = new pipelines.CdkPipeline(this, 'Pipeline', {...});
// Build stage
const buildStage = pipeline.addStage('Build')
const buildOutput = new codepipeline.Artifact();
const buildAction = new actions.CodeBuildAction({
...
buildSpec: codebuild.BuildSpec.fromSourceFilename("buildspec.yml")
}),
// I create a JSON artifact containing the data I want in the artifact
outputs: [buildOutput]
});
buildStage.addActions(buildAction);
// Application stage
const stage = new ApplicationStage(this, "ApplicationStage", {
env: {
account: <id>,
region: <region>
},
...
outputData: buildOutput.getParam("output_file", "output_key")
});
pipeline.addApplicationStage(stage);
// My stage class which is instantiated above
class ApplicationStage extends cdk.Stage {
constructor(scope: cdk.Construct, id: string, props: ApplicationStageProps) {
super(scope, id, props);
// Create a stack which uses the data
new MyStack(this, "MyStack", {data: props.outputData});
};
}
I am seeing errors in CFN when attempting to deploy the application stack:
Template Error: Encountered unsupported function: Fn::GetArtifactAtt Supported functions are: [Fn::Base64, Fn::GetAtt, Fn::GetAZs, Fn::ImportValue, Fn::Join, Fn::Split, Fn::FindInMap, Fn::Select, Ref, Fn::Equals, Fn::If, Fn::Not, Condition, Fn::And, Fn::Or, Fn::Contains, Fn::EachMemberEquals, Fn::EachMemberIn, Fn::ValueOf, Fn::ValueOfAll, Fn::RefAll, Fn::Sub, Fn::Cidr] (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: <id>; Proxy: null)
I have already tried to pass this information using Codepipelines variables that I exported from CodeBuild, but with no luck. Additionally, the cdk.Stage construct does not support parameter overrides as far as I can tell.
Any recommendations for how to pull this off?
P.S. Would prefer not to use Parameter Store as I have multiple deployment stages and want to ensure the specific build output is passed to the correct stage as the correct time. While this is likely doable with the Parameter Store, it introduces unnecessary complexity.
GitHub issue: https://github.com/aws/aws-cdk/issues/15638