AWS Cloudformation“包含”转换问题

时间:2018-12-14 10:06:30

标签: amazon-web-services amazon-cloudformation

AWS Cloudformation在全局模板级别将 Transform 部分定义为数组。
请参见转换节定义here

我在 Transform 部分中创建了两个条目,其中包括堆栈资源的部分定义。 目的是创建一些文件,其中每个文件的定义/资源均按“产品域”分组。

当我基于此模板创建堆栈时,它仅执行一个部分定义(最后一个-使用“ AWS :: Include”名称的其他定义将被忽略或“覆盖”)

这是主要的模板定义:

{
  "AWSTemplateFormatVersion": "2010-09-09",

  "Description": "Test of json file inclusion",

  "Parameters": {
    "Environment": {
      "Type": "String",
      "Description": "Specify Environment: prod | dev ",
      "AllowedValues": ["prod", "dev"],
      "Default": "dev"
    }
  },

  "Transform": [
    {
      "Name": "AWS::Include",
      "Parameters": {
        "Location": "s3://a1-local/cf-tests/part-1.json"
      }
    },
    {
      "Name": "AWS::Include",
      "Parameters": {
        "Location": "s3://a1-local/cf-tests/part-2.json"
      }
    }
  ],

  "Outputs": {
  }
}

这是第1部分的定义

{
  "Mappings": {
      "MappingForBucket1": {
        "eu-west-1": { "AZs": [ "eu-west-1a", "eu-west-1b" ] }
      }
  },

  "Resources": {
    "hellobucket1": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": { "Fn::Sub": "as-testbucket1-${Environment}" }
      }
    }
  }
}

这是第二部分的定义

{
  "Mappings": {
      "MappingForBucket2": {
        "eu-west-1": { "AZs": [ "eu-west-1a", "eu-west-1b" ] }
      }
  },

  "Resources": {
    "hellobucket2": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": { "Fn::Sub": "as-testbucket2-${Environment}" }
      }
    }
  }
}

在这种情况下如何加入/链接多个转换?

0 个答案:

没有答案