I'm using the new pipelines module in aws-cdk to build a multi account code-pipeline deploying a spring boot application to beanstalk.
I followed this tutorial and implemented my own subclass of Cdk.Stage.
This stage class creates a new backend stack:
export class BackendStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, artifact: Artifact, props?: cdk.StackProps) {
super(scope, id, props);
const image = new DockerImageAsset(this, 'backend-image', {
directory: path.join(__dirname, '..', '..', '..', 'backend'),
buildArgs: {
'JAR_FILE': './target/app.jar'
},
})
const dockerRunFile = {
"AWSEBDockerrunVersion": "1",
"Ports": [
{
"ContainerPort": 8080,
"HostPort": 8080
}
],
"Image": {
"Name": image.imageUri
}
}
fs.writeFileSync(path.join(__dirname, 'Dockerrun.aws.json'), JSON.stringify(dockerRunFile));
const versionAsset = new Asset(this, 'version-asset', {
path: path.join(__dirname, 'Dockerrun.aws.json')
})
const appVersionProps = new CfnApplicationVersion(this, 'backend-app-version', {
applicationName: appName,
sourceBundle: {
s3Bucket: versionAsset.bucket.bucketName,
s3Key: versionAsset.s3ObjectKey
}
});
}
...
}
Unfortunately the image.imageUri resolves to Token[TOKEN.219] and not the correct image URI.
I think this has to do with the resolution of Cloudformation tokens.
In my opinion I have to delay the creation of the Dockerrun.aws.json but I don't know how to achieve that.
Is there any other way to pass assets like the Dockerrun.aws.json file to the backend stack ?
I need it to deploy the beanstalk application correctly.