-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to pass a CloudFormation Ref as bucket name #3
Comments
Thank you, use this plugin! To put it briefly, the way of writing is wrong, the correct way to write is as follows. custom:
s3BucketName: (your bucket name)
remover:
buckets:
- ${self:custom.s3BucketName}
resources:
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.s3BucketName} Instead of emptying the S3 bucket with CloudFormation, this plugin empties it with Serverless Framework (Node.js) before CloudFormation deletes the stack. |
Thanks for your answer. That's what I was thinking about. But I was wondering if you had an idea when you don't want to name the bucket, because you want to leave the naming to AWS (since bucket names must be unique among all S3). 😉 |
If CloudFormation does not specify S3's bucket name, it will automatically be named. Then you can use buffet name from the stack information of CloudFormation using service and stage of serverless.yml. |
@sinofseven it is bad practice to hardcode your s3 bucket names. You should be able to deploy numerous times, without being aware of which bucket names are already reserved. This allows for developers to easily deploy to review stages and for CI processes to easily spawn a new infrastructure for automated tests etc. Therefore the request made here is quite a good one and I would say that such references are a must for a plugin like this to be used in production environments. |
@tommedema thank you, your suggestion! |
@sinofseven I'm not currently using this plugin, was just trying to backup @guillaumervls's request :) I'm not sure I understand your question. Let me know if I can be of any help. |
CloudFormation's Ref function has two notations for YAML. # full function
Ref: logicalName
# short form
!Ref logicalName I tried to make it possible to use only short form for this plugin. |
@sinofseven imo it should support normal |
This would be great to have supported! |
I solved it for myself to have unique bucket names generated by CF and exposing it in CF Outputs, and then referencing it in the plugin config: custom:
baseName: someName-${opt:stage}
remover:
buckets:
- ${cf:${self:custom.baseName}.MyBucketToRemoveName, ''}
provider:
name: aws
stage: ${opt:stage}
stackName: ${self:custom.baseName}
resources:
Resources:
# name of this bucket will have a random suffix for uniqueness
MyBucketToRemove:
Type: AWS::S3::Bucket
Outputs:
MyBucketToRemoveName:
Value: !Ref MyBucketToRemove
Export:
Name: ${self:custom.baseName}-MyBucketToRemoveName |
Hi and thanks for this plugin,
However it does not seem to work when passed a CloudFormation "
Ref
", like this :It then says (in the logs) :
Am I missing something ?
Cheers
The text was updated successfully, but these errors were encountered: