I want to use this resource below for my cdk app, I using Python for CDK:
'arn:aws:s3:::${LoggingBucket}/AWSLogs/${AWSAccoutID}/*'
Therefore I need to substitute the value of LoggingBucket and AWSAccountID.
Here is what I tried:
bucket = s3.Bucket(self, "my-bucket", bucket_name = 'my-bucket')
core.Fn.sub('arn:aws:s3:::${LoggingBucket}/AWSLogs/${AWSAccoutID}/*',[bucket.bucket_name, core.Environment.account])
But I get this error for line of core.Fn.sub :
AttributeError: type object 'property' has no attribute '__jsii_type__'
Subprocess exited with error 1
Then I tried this as well:
mappings = {
'LoggingBucket': bucket.bucket_name,
'AWSAccountID': core.Environment.account
}
core.Fn.sub('arn:aws:s3:::${LoggingBucket}/AWSLogs/${AWSAccoutID}/*',mappings)
$ cdk synth
I still getting the same error as above.
Question:
Please give me a solution on how to use the !sub function in cloudformation in CDK. Let me know what I doing wrong as well.
Thank you.