I am working on AWS CloudFormation and I created one template in which I asked user to select Environment.
On the basis of selected value I created the resources. User have to select between DEV, QA, PROD, UAT etc. but when I suffix this value to S3 bucket name (-downloads.com) it not allowed because capital letter is not allowed in S3 bucket name.
So I did change in JSON where I use fn::Transform with "Condition":"Lower" but then while creating resources below error occurs.
No transform named 871247504605::String found.. Rollback requested by user.
Below is my 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": ""
}
}
}
My question is, I want to do lowercase or sometimes uppercase value for S3 bucket or any other resources. How to do this?
Image of template creation error attached.
MyString
macro which is required by aws in order to create custom transformations. More info can be found here. Example (including the lambda function) can be found here. – Molecular ManDEV to dev, PROD to prod, etc
by incorporating mappings and Fn::FindInMap into your template. – Molecular Man