- 최신
- 최다 투표
- 가장 많은 댓글
Hi There
First, you need to store the parameters in a json file (you cant use YAML for the parameters file). Example parameters.json file:
[
{
"ParameterKey": "InstanceType",
"ParameterValue": "t2.micro"
},
{
"ParameterKey": "SecurityGroupId",
"ParameterValue": "sg-xxxxxxxx"
}
]
Then, you deploy your CloudFormation stack using the --parameter-overrides
option.
aws cloudformation deploy --template-file /path_to_template/template.yml --stack-name my-new-stack --parameter-overrides file://path_to_parameters/parameters.json
Reference: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html
Thank you. What about Userdata can it be also passed instead of template.yaml from parameters.json? If yes, How? please guide with full
This is my template.yaml AWSTemplateFormatVersion: "2010-09-09" Parameters: InstanceType: Type: String Default: t2.micro Description: EC2 instance type AMI: Type: AWS::EC2::Image::Id Default: ami-0f8ca728008ff5af4 Description: ID of the Amazon Machine Image (AMI) to use for the instance KeyName: Type: AWS::EC2::KeyPair::KeyName Default: my-key-pair Description: Name of an existing EC2 KeyPair to enable SSH access to the instance SecurityGroupId: Description: Security group ID for the EC2 instance Type: AWS::EC2::SecurityGroup::Id VpcId: Description: VPC ID Type: AWS::EC2::VPC::Id SubnetId: Description: Subnet ID for the EC2 instance Type: AWS::EC2::Subnet::Id RootVolumeSize: Type: Number Default: 0 Description: Size of the root volume in GB DataVolumeSize: Type: Number Default: 0 Description: Size of the data volume in GB Resources: EC2Instance: Type: AWS::EC2::Instance Properties: InstanceType: !Ref InstanceType ImageId: !Ref AMI KeyName: !Ref KeyName SecurityGroupIds: - !Ref SecurityGroupId SubnetId: !Ref SubnetId UserData: !Base64 Fn::Sub: | #!/bin/bash sudo apt-get update sudo apt install apache2 -y sudo systemctl start apache2
관련 콘텐츠
- AWS 공식업데이트됨 7달 전
Please copy code blocks instead of pictures and also please add the issue you have faced
Please guide. how to do it in cloudformation like variables.tf we do in terraform