简体   繁体   中英

get cloudformation parameters from .txt file/s3 bucket

I want to pass input parameter to cloudformation properties from text file or save the text file in s3 bucket and point the s3 URL in CF properties.

Please let me know if this is possible? If yes, how to do?

There isn't a way if you're using the AWS management console to create the CloudFormation stack, but you can if you use the AWS CLI . Save the parameters into a text file (eg parameters.txt ) in one of the following formats:

Shorthand:

ParameterKey=string,ParameterValue=string,UsePreviousValue=boolean ...

JSON:

[
 {
   "ParameterKey": "string",
   "ParameterValue": "string",
   "UsePreviousValue": true|false
 }
 ...
]

Then use the AWS CLI command cloudformation create-stack , eg:

aws cloudformation create-stack --stack-name <YourStackName> \
  --template-body file://<YourTemplateFileName.ext> \
  --parameters file://parameters.txt

Unfortunately it doesn't seem --parameters can reference an S3 bucket directly, only a local file or inline parameters.

See this blog parameter you pass using s3 url:

https://aws.amazon.com/blogs/devops/passing-parameters-to-cloudformation-stacks-with-the-aws-cli-and-powershell/

also try this:

aws cloudformation create-stack --stack-name <YourStackName> \
  --template-body file://<YourTemplateFileName.ext> \
  --parameters $(aws s3 cp S3:/yourbucketname\parameters.txt - )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM