Questions tagged [aws-cloudformation]
For questions about CloudFormation, part of the Amazon Web Services (AWS) that provides a way to manage a collection of related AWS resources.
8,335
questions
24
votes
4
answers
37k
views
In Cloudformation YAML, use a Ref in a multiline string (? use Fn:Sub)
Imagine you have a aws resource such as
Resources:
IdentityPool:
Type: "AWS::Cognito::IdentityPool"
Properties:
IdentityPoolName: ${self:custom.appName}_${self:provider....
24
votes
2
answers
23k
views
Cannot fix "The provided execution role does not have permissions to call CreateNetworkInterface on EC2"
I tried the solutions in this answer but it does not work for me. I am getting the error:
The provided execution role does not have permissions to call CreateNetworkInterface on EC2 (Service: ...
24
votes
5
answers
27k
views
Use CAPABILITY_AUTO_EXPAND for nested stacks on CloudFormation
I am trying to use nested stack and when my ChangeSet is being executed, I got this error:
Requires capabilities : [CAPABILITY_AUTO_EXPAND]
I went and create a pipeline with cloudformation.
This ...
24
votes
1
answer
22k
views
Can I use "Fn::Join" in "Parameters" of AWS Cloudformation json template
I want to use in Parameters of Cloudformation json template shortcut of some Policy/Loadbalancers tags name, like that:
"SomeScalingGroupName": {
"Type": "String",
"Default": {...
24
votes
3
answers
13k
views
The difference between a Stack and Construct in AWS CDK
I'm new to CDK and confused about the difference between a Construct and a Stack. With CDK, we can define reusable cloud components known as Construct, and we can further compose these together into a ...
24
votes
4
answers
13k
views
How do I cloudform an API gateway resource with a lambda proxy integration
I've been trying to work out how to express (in cloudformation) an API Gateway Resource that has a Lambda function integration type using the Lambda Proxy integration.
This is easy to do in the AWS ...
24
votes
2
answers
22k
views
How can I see AWS CloudFormation logs in CloudWatch?
I am not able to view CloudFormation stackset operation logs in the CloudFormation console. Although each stackset operation does have an "Operation ID" Is it possible to see the logs in CloudWatch? ...
23
votes
3
answers
21k
views
How to attach pre-uploaded SSL cert to ELB in CloudFormation template?
I've been trying to attach a SSL certificate that I'm currently using for one of my Elastic Load Balancing Instances on a new Cloud Formation Template but each time I get:
Server Certificate not ...
23
votes
5
answers
17k
views
Creating an Aurora Serverless Cluster from cloudformation?
From Aurora Serverless's document, there are 3 ways to create an Aurora serverless DB cluster: AWS management console, CLI, and RDS API. (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/aurora-...
23
votes
2
answers
16k
views
Unable to define Math Expression for Cloudwatch Alarm in a Cloudformation Template
Recently AWS announced that Cloudwatch alarms can use Math Expressions on metrics. I decided to create an alarm that compares the SUM of 2 single metrics with a given threshold. This means that ...
23
votes
4
answers
51k
views
Multiple conditions in cloud formation resource creation
I'm using a platform condition to control the type of environment that gets spun up on AWS. There are plenty of shared resources, but I need certain EC2 instances with pre-baked AMIs depending on a ...
23
votes
7
answers
13k
views
Do AWS support SES in CloudFormation?
I'm trying to figure out how to automate the creation of several cloud resources in AWS, using CloudFormation.
Now I need to include the creation of SES (Simple Email Service) domain, but couldn't ...
23
votes
2
answers
8k
views
What is the difference between AWS ElastiCache Cluster and AWS ElastiCache Replication Group?
On terraform/cloudformation documentation there are two different resources to create an ElastiCache Redis instance:
aws_elasticache_cluster (https://www.terraform.io/docs/providers/aws/r/...
22
votes
6
answers
42k
views
Associate existing IAM role with EC2 instance in CloudFormation
How can I use an existing IAM role for an EC2 instance, as opposed to creating a new one in my CloudFormation template?
For example, I have created a role in AWS Console and just want to use that.
22
votes
7
answers
27k
views
Configure SQS Dead letter Queue to raise a cloud watch alarm on receiving a message
I was working with Dead letter Queue in Amazon SQS. I want that whenever a new message is received by the queue it should raise a CloudWatch alarm. The problem is I configured an alarm on the metric: ...
22
votes
2
answers
22k
views
Create a Lambda notification in an S3 bucket with CloudFormation
I'm trying to create an S3 trigger for a Lambda function in a CloudFormation Template. The S3 bucket already exists, and the Lambda function is being created.
This says it's not possible to modify ...
22
votes
1
answer
15k
views
PutItem in DynamoDB table by CloudFormation
Is there any way to put items in a DynamoDB table using CloudFormation ?
Something similar to the code in this doc
In the parameter of the template I give the user the possibility to put the values, ...
22
votes
4
answers
11k
views
How to determine what CloudFormation stack an AWS resource belongs to?
Is there a reliable way in boto3 to determine what CloudFormation stack an AWS resource belongs to? Or if it belongs to a stack at all? Say I have a DynamoDB table or an EC2 instance, how do I find ...
22
votes
4
answers
8k
views
Can I setup AWS Cognito User Pool Identity Providers with Cloudformation?
I want to setup a cognito user pool and configure my google identity provider automatically with a cloudformation yml file.
I checked all the documentation but could not find anything even close to ...
21
votes
3
answers
10k
views
What are the benefits of cfn-init over userdata?
My CloudFormation template has gotten pretty long. One reason is because my AWS::CloudFormation::Init section has gotten pretty huge. This is a very small sample of what I have:
"ConfigDisk": {
"...
21
votes
6
answers
35k
views
Lambda does not have permission to access the ECR image
With the recent release of Docker Images for Lambda functions, I've decided to try out this functionality using CloudFormation.
So, the lambda below considers a docker image stored in Elastic ...
21
votes
4
answers
16k
views
AWS CloudFormation Application Load Balancer - how to redirect HTTP listener to HTTPS listener?
I am trying to write a CloudFormation template for ALB, but got stuck on the point where I would like to redirect ALB's HTTP listener's traffic to HTTPS listener. Docs mention only forwarding/...
21
votes
4
answers
21k
views
aws cloudformation lambda python bad handler
I need to create aws Lambda (python) from cloudformation. The lambda function was created, but when I tried to execute the lambda, I keep getting the following error. I have tried many ways and I ...
21
votes
5
answers
28k
views
How to create some random or unique value in a CloudFormation template?
Is there a way to create some kind of random or unique value in a CloudFormation template?
Why I need this. In our templates we have a number of custom-named resources, for instance AWS::AutoScaling::...
21
votes
2
answers
21k
views
How do I specify region in aws cloud formation command line tool for windows
I submit this on command line (i'm omitting all the other params that i know to work)
aws cloudformation create-stack ... --parameters ParameterKey=Region,ParameterValue=us-east-1
It yields:
Unable ...
21
votes
1
answer
28k
views
CloudFormation Parameter Template Error : Parameter is non alphanumeric
I am using
aws cloudformation validate-template --template-body file://template.json
and then getting error:
CloudFormation Parameter Template Error : Parameter is non alphanumeric
Following code ...
21
votes
3
answers
14k
views
AWS ECS Create Scheduled Tasks (cron) via Cloudformation
We want to create ScheduledTasks in AWS ECS via CloudFormation. Is there a programmatic way to create via boto or cloudformation?
21
votes
3
answers
45k
views
RDS does not support creating a DB instance with the following combination
I'm trying to figure out how to create a simple DB instance. I have so far only a DBSubnetGroup and DBInstance. At this point, I've figured out a couple things based on the errors I get when I try to ...
21
votes
5
answers
30k
views
AWS Cloudformation- How to do string Uppercase or lowercase in json/yaml template
I am working on AWS CloudFormation and I created one template in which I asked user to select Environment.
On the basis of selected value I created the resources. User have to select between DEV, QA, ...
20
votes
3
answers
12k
views
Mongodb cluster with aws cloud formation and auto scaling
I've been investigating creating my own mongodb cluster in AWS. Aws mongodb template provides some good starting points. However, it doesn't cover auto scaling or when a node goes down. For example, ...
20
votes
4
answers
16k
views
I'd like to create CloudFormation stack with resources in multiple regions. Is this possible?
Is it possible to create a single Amazon CloudFormation stack template that instantiates an AWS::EC2::Instance in ap-southeast-1 and another AWS::EC2::Instance in us-west-2 for example?
I suspect not,...
20
votes
3
answers
16k
views
Parse an AWS CloudFormation template with the PyYAML library
I am writing a custom Python application using the PyYAML library that needs to read in AWS CloudFormation YAML templates.
I know the templates are valid CloudFormation templates, because I tested ...
20
votes
1
answer
17k
views
Adding lambda target role to AWS Eventbridge rule in Cloudformation fails
I am trying to create an AWS Eventbridge rule with a Lambda function as a target. I can add the rule and target fine but when I try to set the lambda permissions via RoleArn the Cloudformation stack ...
20
votes
1
answer
7k
views
Using Amplify and SAM together?
I'm having some confusion here and wanted to see if someone can set me straight.
I'm using Amplify for a Vue app. It calls API Gateway which calls Lambda and all of this is set up manually but I want ...
20
votes
4
answers
16k
views
How to send SNS notification after cloud formation is completed?
Is it possible to send a SNS notification after the CFT completion in AWS ? Is there any way to get the progress of the launching CFT in AWS.
20
votes
2
answers
7k
views
Can't create a SNS Event source on a Lambda function using CloudFormation
This is the Cloudformation template code related to my problem:
"SNSTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"TopicName": "JumpboxPresenceTopic",
"DisplayName": "Jumpbox ...
20
votes
5
answers
12k
views
AppSync: Get user information in $context when using AWS_IAM auth
In AppSync, when you use Cognito User Pools as your auth setting your identity you get
identity:
{ sub: 'bcb5cd53-315a-40df-a41b-1db02a4c1bd9',
issuer: 'https://cognito-idp.us-west-2....
20
votes
3
answers
30k
views
Using Ref inside Fn::Sub in Cloudformation
I am trying to use fn::sub with a Ref inside it.
I have a string "Comment xyz ${NAME}". This string comes as a parameter to the stack. Say the parameter name is "test".
I would now like to replace ...
20
votes
3
answers
30k
views
CloudFormation Resource Creation if not exist
I want to create Route53 HostedZone with CloudFormation so I want to check some information in Route53 about HostedZone is exist.
In logic of my case I need check if resource is exist, ignore the ...
19
votes
6
answers
17k
views
Serverless: Deplyment error S3 Bucket already exists in stack
I am trying to deploy a serverless project which has s3 bucket creation cloudformation in the serverless.yml file, but the problem is when I tried to deploy, it says the s3 bucket already exists and ...
19
votes
2
answers
7k
views
Auto-Scaling Groups Don't Update on Launch Configuration Change
I have an AWS Auto-Scaling Group, a Launch Configuration, and an Auto-Scaling Group Policy defined in Terraform like this:
resource "aws_autoscaling_group" "default" {
name = "..."
...
19
votes
5
answers
37k
views
How to loop through values in a CloudFormation template
I am trying to pass a list of comma separated parameters in an AWS CloudFormation template and create multiple Amazon S3 buckets based on those values.
I have a requirement where I will be passing a ...
19
votes
1
answer
8k
views
How to set Lambda alarm for specific Lambda using CloudFormation?
This is the structure of CloudFormation Alarm from AWS document.
Type: "AWS::CloudWatch::Alarm"
Properties:
ActionsEnabled: Boolean
AlarmActions:
- String
AlarmDescription: String
...
19
votes
2
answers
24k
views
How can I get current date in a CloudFormation script?
I am tagging my resources using Tags in my cfn script:
"Tags" : [ { "Key" : "Owner", "Value" : "my name" },
{ "Key" : "Name", "Value" : "instance name" }
{ "Key" : ...
19
votes
2
answers
24k
views
What does "!Sub |" mean in AWS UserData field with YAML syntax?
In this example from AWS docs we have a UserData field that allows a multiline string, using the following syntax:
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
yum update -y aws-cfn-...
19
votes
2
answers
14k
views
How to integrate API Gateway with SQS
Just like in the title. I try to integrate API Gateway method with a SQS using cloud formation. What I am missing is the correct URI for the SQS. If any of you already did that, what should the URI ...
19
votes
10
answers
36k
views
Unable to upload artifact None referenced by CodeUri parameter of HelloWorldFunction resource
I'm following this tutorial to learn how to use SAM.
Here's the code I have:
template.yml:
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
...
19
votes
1
answer
61k
views
Template format error: Unresolved resource dependencies
I try to create an EC2 instance with the template below:
Parameters:
KeyName:
Default: TestKeyPair
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Type: ...
19
votes
4
answers
18k
views
AWS Lambda Code in S3 Bucket not updating
I am using cloudformation to create my lambda function with the code in a S3Bucket with versioning enabled.
"MYLAMBDA": {
"Type": "AWS::Lambda::Function",
"Properties": {
"...
19
votes
2
answers
13k
views
CloudFormation - always use latest AMI
The blog post Query for the latest Amazon Linux AMI IDs using AWS Systems Manager Parameter Store | AWS Compute Blog describes how to always reference the latest version of an distribution in a ...