26
votes
How to upload a file into S3 bucket using CloudFormation script?
AWS provides a sample Macro that may help, depending on your use case: https://github.com/awslabs/aws-cloudformation-templates/tree/a11722d/aws/services/CloudFormation/MacrosExamples/S3Objects.
...
19
votes
AWS CloudFormation - Custom variables in templates
I don't have an answer, but did want to point out that you can save yourself a lot of pain by using Fn::Sub in place of Fn::Join
{ "Fn::Sub": "${ELBHostName"}-1.${EnvironmentVersioned}.${HostedZone}"}...
17
votes
Accepted
Cloudformation fails with "AMI cannot be described"
The AMI was deleted by another user at the same time I did my edits.
The message "AMI cannot be described" actually means "AMI could not be found".
Hope this helps someone.
16
votes
Accepted
Can FindInMap return a list?
Using the Split function works:
JSON
"Mappings": {
"AWSEnv2PublicSubnets": {
"DEV": {
"subList": "subnet-1111,subnet-2222,subnet-3333"
}
}
}
then:
"Subnets" : {
...
14
votes
Accepted
Is it possible to force Re-creation of EC2::Instance or RDS::DBInstance in amazon cloudformation?
For instance store-backed EC2 instances, one trick is to add a comment to the user data script containing a version number, date, or similar, then change that whenever you want the instance recreated:
...
14
votes
Cloudformation can I create a new role referencing an existing policy?
src: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html
The AWS::IAM::Role types now have a ManagedPolicyArns field where you can set this. You just need to ...
12
votes
Referring to an existing resource in CF Template
I recently had to do this for some layered deployments which referenced shared services. In addition to parameters, here are some other options:
Named exports: this is a good option if you have some ...
12
votes
Accepted
Can't SSH into AWS CloudFormation Stack Instance
The problem is that the CloudFormation template creates a RouteTable with the default route 0.0.0.0/0 correctly pointing to the IGW, however you don't associate the RouteTable with your subnets.
What ...
11
votes
How do I get AWS CloudFormation to recreate a resource I manually deleted?
The easiest way is to give the EC2 instance a different resource name and update the stack. Cloudformation will interpret that as you creating an entirely new instance and create it.
Another ...
11
votes
Can FindInMap return a list?
I think Mappings value supports List type (at least as of now).
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html
The Mappings section consists of the ...
10
votes
How to retrieve AWS SNS Arn value
In your CloudFormation template, if you simply reference your SNS topic, then you'll get the ARN.
For example:
{ "Ref": "MySnsTopic" }
So you can use that as input to your nested CloudFormation ...
9
votes
Amazon CloudFormation: How to get an ELB's private IP for a specific subnet?
If you want to get the private ip address of an elb, check network interfaces under network and security in you ec2 dashboard.
9
votes
How to specify VPC and subnet in AWS CloudFormation template
If you want to continue using default VPC you deleted you will have to contact AWS support to create it again. AWS resources from the template you are using depnd on it.
Otherwise you have to ...
8
votes
Specifying a VPC in a CloudFormation template for an EC2 instance
For EC2 Instances, you get to skip specifying the VPC ID and instead, just specify the subnet you want the instance in. From there, the VPC is assumed.
Inside of your "Properties" array, add the ...
8
votes
specify root volume size for ec2 instance in cloudformation
I had been stuck for days to change root-disk size using Cloudformation, , this is how it works for me..
If you use /dev/xvda1 the instance will fail, the correct way is to use /dev/xvda.
Using YAML ...
8
votes
Accepted
how to pull docker image on ECR using cloudformation template
Using ECR, EC2 and docker, you are still required to do a docker login.
In the user data run
aws ecr get-login --no-include-email > login.sh
bash login.sh
then you should be able to run
...
7
votes
Accepted
AWS CloudFormation - Custom variables in templates
I was looking of the same functionality. Using a nested stack as SpoonMeiser suggested came to mind, but then I realised that what I actually needed was custom functions. Luckily CloudFormation allows ...
7
votes
Amazon CloudFormation: How to get an ELB's private IP for a specific subnet?
JQ parsing version, just FYI.
aws ec2 describe-network-interfaces --filters "Name=description,Values=ELB your-elb-name" --output json | jq ".NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress"
6
votes
How do I associate an ssh key pair with the instance created by a stack in Amazon CloudFormation?
AWS CloudFormation parameters can also give you a list of all key's that are available in your account & region. Just change the "Type" of the parameter to the desired AWS type. That will be "AWS::...
6
votes
AWS Cloudformation - can't add multiple subnet associations to a public routing table
As @Marcus explained in his response to his own question; it is the lack of the DependsOn attribute when you create an AWS::EC2::Route entry where you specify a Gateway.
For route entries that ...
6
votes
AWS Cloud Formation.Requires capabilities : [CAPABILITY_IAM] (Child Stack)
I just ran into this issue, my problem was that I did not check the checkbox "I acknowledge that this template might cause AWS CloudFormation to create IAM resources." on the last screen before ...
6
votes
Unable to mount EBS drives to an Ubuntu box using AWS CloudFormation (UserData not working)
Here's the answer - the EBS needs to be attached fully.
"UserData": {
"Fn::Base64": {
"Fn::Join": ["",
[
...
6
votes
Passing parameters to AWS Lambda
You can pass ES cluster endpoint to Lambda function as an environment variable. Here is a snippet of CloudFormation template for such function:
"mylambda": {
"Type": "AWS::Lambda::Function",
"...
6
votes
Accepted
Configuring X-Ray in Lambda with AWS CloudFormation vs TracingConfig
While not clear, TracingConfig is the setting to enable AWS X-Ray.
TracingConfig is a property of the AWS::Lambda::Function resource that configures tracing settings for your AWS Lambda (Lambda) ...
6
votes
Accepted
AWS::CloudFormation::Init not executing commands
You have to execute cfn-init in order for AWS::CloudFormation::Init to do anything. This is most commonly done via cloud-init user data. Here is the example from the cfn-init documentation:
UserData: ...
5
votes
Creating AWS VPC Endpoints with CloudFormation
This is what you're looking for:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html
AWS::EC2::VPCEndpoint
The AWS::EC2::VPCEndpoint resource creates a VPC ...
5
votes
Accepted
How to get public IP of instance in CloudFormation template when using LaunchConfig
If your UserData contains a shell script and all you need to do is reference the instance's own public IP within that script, you can get this value by querying the public-ipv4 category of the ...
5
votes
Accepted
Cloud Formation template add ingress rule to existing security group
Yes, it can be done.
You need to pass the security group identifier (for Security Group A) into the template for Template B as a parameter. From there, you can reference Security Group A in a AWS::...
5
votes
Accepted
CloudFormation stack yaml syntax?
You have an extra '-' character in the Tags definition. It should look something like the snippet below (I'm not sure of the Join syntax, personally I use Sub normally):
Tags:
- Key: Name
...
5
votes
Accepted
CloudFormation template: how to use Sub and GetAtt at the same time in short form?
Simply remove !GetAtt and reference the desired variable. In the following code EIP.AllocationId normally returned via !GetAtt.
!Sub |
#!/bin/bash
export INSTANCEID=$(curl -s http://169.254.169....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
amazon-cloudformation × 263amazon-web-services × 201
amazon-ec2 × 63
amazon-elb × 13
amazon-iam × 13
amazon-s3 × 11
amazon-vpc × 11
amazon-route53 × 10
autoscaling × 9
amazon-ecs × 9
amazon-lambda × 9
amazon-rds × 8
elastic-beanstalk × 6
linux × 5
aws-cli × 5
yaml × 5
load-balancing × 4
puppet × 4
deployment × 4
amazon-api-gateway × 4
ubuntu × 3
cloud × 3
automation × 3
amazon-cloudfront × 3
terraform × 3