![]() If we specify a local template file, AWS CloudFormation uploads it to an Amazon S3 bucket in our AWS account. $ aws cloudformation create-stack -stack-name myteststack2 -template-body file:// /home/k/TEST/CloudFormation/ec2-instance-with-sg.template -parameters ParameterKey=KeyName,ParameterValue=einsteinishĪrn:aws:cloudformation:us-east-1:526262051452:stack/myteststack2/cbc84e30-2e21-11e7-8841-500c28637435 In the command, we specified "S3 url", however, we can use local template file ( -template-body file://): "ConstraintDescription" : "must be the name of an existing EC2 KeyPair." "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", Note that the parameters in "ParameterKey= KeyName" should match the one in the template file. $ aws cloudformation create-stack -stack-name myteststack -template-url -parameters ParameterKey=KeyName,ParameterValue=einsteinishĪrn:aws:cloudformation:us-east-1:526262051452:stack/myteststack/89192290-2e1b-11e7-893d-50a686e4bb1e If we mistype a parameter key name when we run aws cloudformation create-stack, AWS CloudFormation doesn't create the stack and reports that the template doesn't contain that parameter. Parameters are separated with a space and the key names are case sensitive. We must provide the stack name, the location of a valid template, and any input parameters. To create a stack we run the aws cloudformation create-stack command. PARAMETERS t2.small WebServer EC2 instance typeğalse InstanceType PARAMETERSĐ.0.0.0/0 The IP address range that can be used to SSH to the EC2 instancesğalse SSHLocation PARAMETERS Name of an existing EC2 KeyPair to enable SSH access to the instanceğalse KeyName You will be billed for the AWS resources used if you create a stack from this template. **WARNING** This template creates an Amazon EC2 instance. This example creates an EC2 security group for the instance to give you SSH access. The AMI is chosen based on the region in which the stack is run. $ aws cloudformation validate-template -template-url ĪWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSample: Create an Amazon EC2 instance running the Amazon Linux AMI. We can check our template file for syntax errors using aws cloudformation validate-template command: To delete non-empty bucket, we use "-force" flag: Or we can copy an object into a bucket with -grants read permissions on the object to everyone and full permissions (read, readacl, and writeacl) to the account associated with aws s3 cp ok2.txt s3://my-bucket-einsteinish/ -grants read=uri= this one, we may edit the permission from "Deny" to "Allow" for the "Effect" since it's been created by "BeanStalk". ecs-jenkins.json to s3://bogo-aws/ecs/jenkins/ecs-jenkins.json $ aws s3 cp ecs-jenkins.json s3://bogo-aws/ecs/jenkins/ THe following command will create ecs/jenkins and copy "ecs-jenkins.json" to bogo-aws/ecs/jenkins/: $ aws s3 cp ok.txt s3://my-bucket-einsteinish/ok.txt To upload a file to a bucket ( aws s3 cp, aws s3 mv, and aws s3 sync): Instance profile credentials - these credentials can be used on EC2 instances with an assigned instance role, and are delivered through the Amazon EC2 metadata service.įor more : Configuring the AWS Command Line Interface.This file can contain a default profile, named profiles, and CLI specific configuration parameters for each. The CLI configuration file - typically located at ~/.aws/config on Linux, OS X, or Unix, or at C:\Users\USERNAME \.aws\config on Windows.This file can contain multiple named profiles in addition to a default profile. The AWS credentials file - located at ~/.aws/credentials on Linux, OS X, or Unix, or at C:\Users\USERNAME \.aws\credentials on Windows.Environment Variables - AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.Command Line Options - region, output format and profile can be specified as command options to override default settings.The AWS CLI looks for credentials and configuration settings in the following order: The above commands put Access Key ID and Secret Access Key to ~/.aws/config and ~/.aws/credentials:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |