-
Notifications
You must be signed in to change notification settings - Fork 4.5k
use FnJoin in bucketName property #624
Copy link
Copy link
Closed
Labels
bugThis issue is a bug.This issue is a bug.
Description
Hi everyone,
I am using a cdk.Parameter object to define the stage of my CloudFormation stack and I would like to use this object to define a bucket name, doing so I'll have a bucket related to production, dev, test, etc...
In order to achieve this result I am doing as follow:
new Bucket(this, this.name.toLowerCase(), {
bucketName: new FnJoin("", [this.name.toLowerCase(), "-", DefaultParameters.getParameter(this.parent, DefaultParameters.PARAMETERS.stage)]).toString(),
versioned: true
});
where
DefaultParameters.getParameter(this.parent, DefaultParameters.PARAMETERS.stage)
return a cdk.Parameter object.
When I run
cdk synth --output tmp
I receive this error:
/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/node_modules/@aws-cdk/aws-s3/lib/util.js:9
throw new Error('Bucket name contains invalid characters: ' + bucketName);
^
Error: Bucket name contains invalid characters: ${Token[TOKEN.5]}
at Object.validateBucketName (/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/node_modules/@aws-cdk/aws-s3/lib/util.js:9:15)
at new Bucket (/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/node_modules/@aws-cdk/aws-s3/lib/bucket.js:172:16)
at new TestBucket (/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/build/lib/s3/testBucket.js:10:23)
at new MainStack (/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/build/stacks/main_stack.js:23:25)
at new MyApp (/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/build/index.js:22:9)
at Object.<anonymous> (/Users/dodo/Desktop/Dev/Code/Projects/pvideosmart/pvideosmart-aws-infrastructure/build/index.js:25:22)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
I have tried to comment the following line from @aws-cdk/aws-s3/lib/bucket.js:
util_1.validateBucketName(props && props.bucketName);
Doing so I obtain the desired result in the output template which is:
pvideosmartweb94A59098:
Type: 'AWS::S3::Bucket'
Properties:
BucketName:
'Fn::Join':
- ""
-
- pvideo-smart-web
- '-'
-
Ref: stage
VersioningConfiguration:
Status: Enabled
Am I missing something or there is a problem in the s3 bucket's name verifcation process?
Thank you.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.