Skip to content
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

UpdateReplacePolicy is removed from AWS::S3::Bucket on transform #1807

Closed
mhart opened this issue Nov 18, 2020 · 2 comments
Closed

UpdateReplacePolicy is removed from AWS::S3::Bucket on transform #1807

mhart opened this issue Nov 18, 2020 · 2 comments
Labels
stage/pr Has a PR ready for review

Comments

@mhart
Copy link

mhart commented Nov 18, 2020

Description:

cfn-lint highlighted an issue where SAM removes UpdateReplacePolicy from an AWS::S3::Bucket resource: aws-cloudformation/cfn-lint#1265 (comment)

I commented over at #450 (comment) but there has been no response in a few months (it's actually unclear whether this is the same issue).

Steps to reproduce the issue:

Original SAM template:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:

  Bucket:
    Type: AWS::S3::Bucket
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain

  Function:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs12.x
      Events:
        ObjectCreated:
          Type: S3
          Properties:
            Bucket: !Ref Bucket
            Events: s3:ObjectCreated:*

Observed result:

(just the bucket portion)

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  Bucket:
    DeletionPolicy: Retain
    DependsOn:
    - FunctionObjectCreatedPermission
    Properties:
      NotificationConfiguration:
        LambdaConfigurations:
        - Event: s3:ObjectCreated:*
          Function:
            Fn::GetAtt:
            - Function
            - Arn
    Type: AWS::S3::Bucket

Expected result:

(just the bucket portion)

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  Bucket:
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    DependsOn:
    - FunctionObjectCreatedPermission
    Properties:
      NotificationConfiguration:
        LambdaConfigurations:
        - Event: s3:ObjectCreated:*
          Function:
            Fn::GetAtt:
            - Function
            - Arn
    Type: AWS::S3::Bucket
@sriram-mv
Copy link
Contributor

Got a repro and its a fairly simple fix.

@sriram-mv sriram-mv added stage/pr Has a PR ready for review and removed type/bug labels Apr 11, 2021
@mndeveci
Copy link
Contributor

mndeveci commented Jun 9, 2021

Closing this issue since it is been released with SAM v1.36.0 and SAM CLI v1.24.0.

You can read more about how resource level attributes are handled in SAM via our updated documentation; https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-resource-attributes.html

Thanks!

@mndeveci mndeveci closed this as completed Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/pr Has a PR ready for review
Projects
None yet
Development

No branches or pull requests

4 participants