dougmoscrop/serverless-plugin-split-stacks

Commit "Fix side effect when referencing the same resource in multiple stacks" breaks deployment

carlcheel-sage opened this issue · 2 comments

Following the addition of commit 8273717... the ServerlessDeploymentBucketPolicy has the incorrect ref when building.

Before commit 827371789a07144977d59de4690b73a3fb777dfb (works fine):

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "PoliciesNestedStack nested stack",
  "Parameters": {
    "ServerlessDeploymentBucketParameter": {
      "Type": "String"
    }
  },
  "Resources": {
    "ServerlessDeploymentBucketPolicy": {
      "Type": "AWS::S3::BucketPolicy",
      "Properties": {
        "Bucket": {
          "Ref": "ServerlessDeploymentBucketParameter"
        },
        "PolicyDocument": {
          "Statement": [
            {
              "Action": "s3:*",
              "Effect": "Deny",
              "Principal": "*",
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:",
                      {
                        "Ref": "AWS::Partition"
                      },
                      ":s3:::",
                      {
                        "Ref": "ServerlessDeploymentBucketParameter"
                      },
                      "/*"
                    ]
                  ]
                }
              ],
              "Condition": {
                "Bool": {
                  "aws:SecureTransport": false
                }
              }
            }
          ]
        }
      },
      "DependsOn": []
    }
  },
  "Outputs": {}
}

After (broken due to incorrect Ref):

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "PoliciesNestedStack nested stack",
  "Parameters": {
    "ServerlessDeploymentBucketParameter": {
      "Type": "String"
    }
  },
  "Resources": {
    "ServerlessDeploymentBucketPolicy": {
      "Type": "AWS::S3::BucketPolicy",
      "Properties": {
        "Bucket": {
          "Ref": "ServerlessDeploymentBucket"
        },
        "PolicyDocument": {
          "Statement": [
            {
              "Action": "s3:*",
              "Effect": "Deny",
              "Principal": "*",
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:",
                      {
                        "Ref": "AWS::Partition"
                      },
                      ":s3:::",
                      {
                        "Ref": "ServerlessDeploymentBucket"
                      },
                      "/*"
                    ]
                  ]
                }
              ],
              "Condition": {
                "Bool": {
                  "aws:SecureTransport": false
                }
              }
            }
          ]
        }
      },
      "DependsOn": []
    }
  },
  "Outputs": {}
}

Confirmed the issue is caused by _cloneDeep on Line 234 and Line 239. Removing this fixes the issue.

Closed as duplicate of issue #82