Cloudformation - adding string in middle
I am trying to concatenate sting in AWS Cloudformation, I am getting error, tried various things . No luck. Enviroment is a Parameter. I am trying to make EndpointIdentifier with join but it doesn't work. Please let me know the correct format. Error message - Template error: every Fn::Join object requires two parameters, (1) a string delimiter and (2) a list of strings to be joined or a function that returns a list of strings (such as Fn::GetAZs) to be joined.
End result should be for e.g if dev is choosen from dropdown - fp-epk-dev-dms-source or fp-epk-dev-dms-target Removed some code which is not required for this question
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Enviroment:
Type: String
Default: "dev"
AllowedValues:
- "dev"
- "uat"
- "prod"
Resources:
DMSSourceEndpoint:
Type: "AWS::DMS::Endpoint"
Properties:
EndpointIdentifier: !Join
- ''
- 'fp-epk-'
- !Ref Enviroment
- '-dms-source'
EngineName: "ORACLE"
EndpointType: "source"
Username: !Ref Username
Password: !Ref Password
ServerName: !Ref SourceServer
Port: !Ref SourcePort
DatabaseName: !Ref SourceDatabase
ExtraConnectionAttributes: "addSupplementalLogging=Y"
DMSTargetEndpoint:
Type: "AWS::DMS::Endpoint"
Properties:
EndpointIdentifier: !Join
- ''
- '-epk-'
- !Ref Enviroment
- '-dms-target'
EngineName: "S3"
EndpointType: "target"
Hi, I hope you're keeping well today.
The intrinsic function Fn::Sub would be best for this scenario [1]. So you have your parameter defined like:
Enviroment:
Type: String
Default: "dev"
AllowedValues:
- "dev"
- "uat"
- "prod"
Then in your AWS::DMS::Endpoint resource, for the 'EndpointIdentifier' option define it something like:
Description: "Endpoint test"
Resources:
BasicEndpoint:
Type: "AWS::DMS::Endpoint"
Properties:
....
EndpointIdentifier: !Sub 'fp-epk-${Environment}-dms-target'
....
....
This will populate the psuedo parameter ${Environment} with the value you selected for the parameter Environment.
I hope you find this useful. If you have any additional queries, please let me know!
REFERENCES:
[1] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html
Relevant questions
Cloudformation - adding string in middle
Accepted Answerasked 25 days agoI am unable to customise my AWS SSO URL
asked 2 months agoAPI Gateway V1 Build Issue - CloudFormation
asked 2 years agoUsing pseudo parameters as defaults in cloudformation
Accepted Answeraws cloudformation delete-stack command failing
asked 2 years agoI am getting CORS errors in S3 console, is this a bug with AWS S3?
asked 2 months agoI am trying to write an ETL job to the Data Catalog but its writing the Headers as Data
Accepted Answerasked 3 months agoHow to declare multi region access point in cloudformation template
asked 12 days agoWhy am I getting a 503 Service Temporarily Unavailable error?
asked a year agoI am trying to deploy the EKS cluster using s3 template but getting errors, please help me
asked 5 months ago
Thank you this worked, Thanks for the reply, thanks sir.