in packages/@aws-c2a/cdk-pipelines-step/lib/private/web-app-bucket.ts [65:102]
constructor(scope: Construct, id: string, props?: WebAppBucketProps) {
super(scope, id);
this.bucket = new s3.Bucket(scope,' C2AWebAppBucket', {
autoDeleteObjects: props?.autoDeleteObjects ?? true,
publicReadAccess: false,
removalPolicy: RemovalPolicy.DESTROY,
});
this.user = new iam.User(this, 'C2ADownloadUser');
const accessKey = new iam.CfnAccessKey(this, 'C2ADownloadUserKey', {
userName: this.user.userName,
});
this.accessKeySecret = new secrets.Secret(this, 'AccessKeySecret', {
description: 'Secret holding the access key for the IAM user we use to pre-sign URLs',
});
(this.accessKeySecret.node.defaultChild as secrets.CfnSecret).generateSecretString = undefined;
(this.accessKeySecret.node.defaultChild as secrets.CfnSecret).secretString = Stack.of(this).toJsonString({
AWS_ACCESS_KEY_ID: accessKey.ref,
AWS_SECRET_ACCESS_KEY: accessKey.getAtt('SecretAccessKey'),
});
this.bucket.grantRead(this.user);
this.putObject =
'aws s3api put-object' +
` --bucket ${this.bucket.bucketName}` +
' --key $CODEPIPELINE_EXECUTION_ID/$STAGE_NAME/index.html' +
' --body index.html' +
' --content-type text/html';
this.signObject =
'env AWS_ACCESS_KEY_ID=$DOWNLOAD_USER_KEY AWS_SECRET_ACCESS_KEY=$DOWNLOAD_USER_SECRET' +
' aws s3 presign' +
` s3://${this.bucket.bucketName}/$CODEPIPELINE_EXECUTION_ID/$STAGE_NAME/index.html` +
' --expires-in 604800';
}