我正在使用AWS CloudFormation,创建了一个模板,在其中要求用户选择环境。
根据所选的值,我创建了资源。用户必须在DEV、QA、PROD、UAT等之间进行选择,但是当我将这个值添加到S3存储桶名称(-downloads.com)中时,不允许使用大写字母,因此我在JSON中做了更改,使用fn::Transform和"Condition":"Lower"。
但是在创建资源时,出现以下错误:
No transform named 871247504605::String found.. Rollback requested by user.
以下是我的CloudFormation JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Provides nesting for required stacks to deploy a full resource of ****",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {
"default": "Enviroment Selection"
},
"Parameters": [
"selectedEnv"
]
}
],
"ParameterLabels": {
"selectedEnv": {
"default": "Please select Enviroment"
}
}
}
},
"Parameters": {
"selectedEnv": {
"Type": "String",
"Default": "DEV",
"AllowedValues": [
"DEV",
"QA",
"UAT",
"PROD"
]
}
},
"Resources": {
"S3BucketName": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": {
"Fn::Join": [
"",
[
{
"Fn::Transform": {
"Name": "MyString",
"Parameters": {
"InputString": {
"Ref": "selectedEnv"
},
"Operation": "Lower"
}
}
},
"-deployment.companyname.com"
]
]
},
"PublicAccessBlockConfiguration": {
"BlockPublicAcls": "true",
"BlockPublicPolicy": "true",
"IgnorePublicAcls": "true",
"RestrictPublicBuckets": "true"
},
"Tags": [
{
"Key": "ENV",
"Value": {
"Ref": "selectedEnv"
}
},
{
"Key": "Name",
"Value": {
"Fn::Join": [
"",
[
{
"Ref": "selectedEnv"
},
"deployments"
]
]
}
}
]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "c81705e6-6c88-4a3d-bc49-80d8736bd88e"
}
}
},
"QueueForIOT": {
"Type": "AWS::SQS::Queue",
"Properties": {
"QueueName": {
"Fn::Join": [
"",
[
{
"Ref": "selectedEnv"
},
"QueueForIOT"
]
]
},
"DelaySeconds": "0",
"MaximumMessageSize": "262144",
"MessageRetentionPeriod": "345600",
"ReceiveMessageWaitTimeSeconds": "20",
"VisibilityTimeout": "30"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "6484fbb7-a188-4a57-a40e-ba9bd69d4597"
}
}
}
},
"Outputs": {
"Help": {
"Description": "This is description",
"Value": ""
}
}
}
我的问题是,我想将S3存储桶或其他资源的值转换为小写或大写。如何做到这一点?
附有模板创建错误的图像。
MyString
宏的 lambda 函数,这是 AWS 创建自定义转换所必需的。更多信息可以在这里找到。示例(包括 lambda 函数)可以在这里找到。 - Molecular ManDEV到dev,PROD到prod等
。 - Molecular Man