- Neueste
- Die meisten Stimmen
- Die meisten Kommentare
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
Relevanter Inhalt
- AWS OFFICIALAktualisiert vor 2 Jahren
- AWS OFFICIALAktualisiert vor 3 Jahren
- AWS OFFICIALAktualisiert vor einem Jahr
- AWS OFFICIALAktualisiert vor einem Jahr
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