All Questions
Tagged with aws-cloudformation yaml
438
questions
85
votes
7
answers
37k
views
AWS SAM YAML template - Unknown Tag !Ref
When I try to deploy my AWS SAM YAML file, it fails saying the !Ref is an unknown tag.
Any ideas to get around this?
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
74
votes
4
answers
51k
views
How to use Sub and GetAtt functions at the same time in CloudFormation template?
I created CloudFormation yaml template and I need to use !GetAtt "TestLambda.Arn" as part of !Sub function in "AWS::ApiGateway::Method" Integration Uri:
Type: "AWS::ApiGateway:...
29
votes
8
answers
20k
views
Cloudformation Cognito - how to setup App Client Settings, Domain, and Federated Identities via SAM template
I already have my cognito user pool cloudformation template working, and have it integrated to my api gateway. But somehow i still have to manually configure the app client settings, domain, and ...
28
votes
3
answers
55k
views
How do I pass a list of strings as a parameter in CloudFormation?
I've got a nested CloudFormation template which accepts a number of parameters from its root template to configure it. At the moment I'm only passing simple string parameters but now I need to pass a ...
28
votes
1
answer
41k
views
How to reference a resource ARN in a cloudformation policy document ? (yaml)
I am trying to define a trust relationship policy document between a role and a user in cloudformation (yaml).
For specifying the ARN of the user in the role's AssumeRolePolicyDocument, I want to ...
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....
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 ...
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-...
17
votes
2
answers
13k
views
How do I supply different conditions based on a parameter in an IAM Role CloudFormation Template
I'm writing a CloudFormation template for an IAM role that I will assume through STS. I need to add a condition where a key equals a value, where both the key and value depends on a "Stage" parameter. ...
16
votes
6
answers
21k
views
AWS CloudFormation: Combining ImportValue and Sub functions causes error
When uploading my template to CloudFormation I am receiving the following validation error:
Template validation error: Template error: the attribute in
Fn::ImportValue must not depend on any ...
13
votes
2
answers
22k
views
AWS Cloud Formation !Sub & !Ref functions inside AWS::Serverless::Function Policies
I have been using the !Sub function in my CloudFormation Yaml templates just fine. And when used it as an object property value it works for me
Object:
Property1: !Sub some-value-with-a-${variable}-...
11
votes
3
answers
13k
views
Cloudformation YAML custom variable
I am trying to achieve something similar to below in a AWS Cloudformation YAML file:
AWSTemplateFormatVersion: 2010-09-09
testAttribute = "test"
Resources:
Lambda:
Type: AWS::Lambda::...
10
votes
2
answers
14k
views
AWS Cloud Formation; Breaking up template into several files and passing in variables with cfn-include
I'm running into some issues with my aws cloud formation template.
I have a general staging.yaml file where I define all my lambdas and apis.
Problem is, that file has gotten WAY too big.
So I ...
8
votes
3
answers
5k
views
AWS CLI- What is the syntax for assigning multiple values on a parameter
For example, I have this CF template that ask for these parameters
----- cftemplate.yaml -----
...
Parameters:
**Subnet:
Description: Subnet for the Instance
Type: 'AWS::EC2::Subnet::Id'
...
8
votes
1
answer
15k
views
add S3 trigger on a Lambda function with cloudformation yaml
So I have this issue that I would love to:
Create an S3-bucket
Add this S3 bucket as a trigger to the current lambda function I'm using.
This is something which has to be done in YAML
I have no ...
7
votes
1
answer
15k
views
How do I implement a DynamoDB Global Secondary Index with Infrastructure As Code in CloudFormation
I am working on implementing a GSI in CloudFormation with Infrastructure As Code. All I want to do is use this table to keep count of the entries in the main DynamoTable. Here is what the main tale ...
7
votes
1
answer
3k
views
What is double colon in yaml ? I'm seeing in AWS Cloud Formation
I'm sorry if this is a noob question for you but I seriously don't understand the double colon here. What does it mean ?
"Type": "AWS::EC2::KeyPair::KeyName"
I understand basic YAML syntax and ...
7
votes
1
answer
8k
views
UserData script with Resource Attribute CloudFormation
The main question: How to I reference dependent resource attributes in a cloud formation template to build out a user data script.
What I have tried:
Approach listed here.
Examples from sub ...
6
votes
2
answers
10k
views
Cloudformation nested stack outputs in yaml
In my nested stacks I need to use output values and AWS::CloudFormation::Stack returns values as
Fn::GetAtt
Outputs.NestedStackOutputName
But yaml doesn't allow me to use
!GetAtt MyResourceName....
6
votes
5
answers
5k
views
Start cfn-init in Ubuntu instance with cloudformation (yaml)
I try to start the cfn-init with:
Fn::Base64: !Sub |
#!/bin/bash
sudo apt-get -y install python-setuptools
mkdir aws-cfn-bootstrap-latest
curl https://s3.amazonaws.com/cloudformation-...
6
votes
1
answer
6k
views
Can I define tags as a parameter in parameters section AWS CloudFormation template
Can I define tags as a parameter in parameters section AWS CloudFormation template and use it in each created resource?
My current template:
AWSTemplateFormatVersion: 2010-09-09
Description: "Some ...
6
votes
2
answers
4k
views
How can I write nested IF in serverless.yml using yaml format file while using it for cloud formation?
I'm trying to access secrets created in secrets manager(https://aws.amazon.com/secrets-manager/) via SSM (Systems Manager- https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-...
6
votes
2
answers
3k
views
Cloudformation how to Sub inside of a ImportValue inside of a Sub?
I feel I have tried just about every combination for this to work, and have come up empty handed. Has anyone done this? I am trying to reference an import value inside of a sub while referencing the ...
5
votes
1
answer
12k
views
CloudFormation YAML - IAM policy with a statement that has a condition
I have an IAM Policy that was created automatically when creating another resource in the AWS Console. I'm trying to add this into an existing CloudFormation stack.
The policy has the following ...
5
votes
2
answers
16k
views
Error on run: Property validation failure: [Value of property {/Targets/0/Values} does not match type {Array}]
This CF is being created in YAML not JSON.
I am building Systems Manager Maintenance Windows, Targets and Tasks through Cloudformation.
When creating the stack, the Resources: MaintenanceWindow: ...
5
votes
3
answers
7k
views
Error creating BucketPolicy in CloudFormation yaml
I'm trying to use the following yaml to create an S3 Bucket Policy in CloudFormation:
cloudTrailBucketPolicy:
Type: "AWS::S3::BucketPolicy"
Properties:
Bucket:
Ref: ...
5
votes
2
answers
7k
views
How to Parse YAML Using PyYAML if there are '!' within the YAML
I have a YAML file that I'd like to parse the description variable only; however, I know that the exclamation points in my CloudFormation template (YAML file) are giving PyYAML trouble.
I am ...
5
votes
1
answer
2k
views
How does one escape policy variables in AWS CloudFormation YAML templates
I have been trying to write a number of my AWS CloudFormation templates in the YAML format.
I have been having issues with CloudFormation trying to parse IAM policy variables, such as ${aws:username},...
5
votes
1
answer
3k
views
CloudFormation yaml - How to force number type?
I'm trying to create an ECS task definition as part of a CloudFormation stack.
My task definition so far looks like this...
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
...
5
votes
1
answer
12k
views
How can I request parameters in api gateway using cloudformation in aws and pass it down to lambda function?
I am trying to request parameters using API Gateway in AWS CloudFormation. The parameter that I want to pass down from API gateway to Lambda function is 'action'. I have tried the following code and ...
5
votes
1
answer
3k
views
How to set up Custom Domain names with Route53 in AWS SAM Cloud-Formation
ORIGINAL QUESTIONS: How to get RegionalDomainName out of a AWS APIGateway DomainName in SAM Cloud-formation
EDIT: I changed the question to hopefully get more traffic to this answer as it answers ...
4
votes
4
answers
7k
views
Using importValue inside If Condition in aws cloudformation templates
I'm trying to find a way to use ImportValue inside If function but can't find a proper syntax. Any help is appreciated.
Below the code I'm trying:
SomeTaskdefinition:
Type: AWS::ECS::TaskDefinition
...
4
votes
2
answers
12k
views
Iterate over array of AWS cloudformation resources in template
When creating resources in AWS CloudFormation from a yml (or json) template, is it possible to iterated over an array to keep the template brief and readable. For example, I have an Appsync project ...
4
votes
2
answers
7k
views
How do I pass arguments to a Glue job in CloudFormation YAML?
You can pass arguments to an AWS Glue job via the --arguments parameter (see here).
The CloudFormation documentation says DefaultArguments are "UTF-8 string–to–UTF-8 string key-value pairs" and that ...
4
votes
2
answers
7k
views
CloudFormation: How to use AWS::AccountId in Mappings?
I have a mapping that looks like this:
Mappings:
AccountToParams:
aws-1234567890:
sshSecurityGroup: sg-abcedf12
And I'd like to retrieve my variables by AccountId, but this doesn't get ...
4
votes
2
answers
3k
views
Fn::ImportValue does not match type {Array}
I faced an issue with using the export and import functionality in CloudFormation. When I tried to import a value which actually is a list (array) I received the following error message "does not ...
4
votes
2
answers
5k
views
Endpoint Configuration type EDGE is not supported in this region
I'm trying to launch a AWS API Gateway via CloudFormation (YAML + Swagger).
When trying to launch the stack via the console I keep getting;
"Endpoint Configuration type EDGE is not supported in this ...
4
votes
2
answers
5k
views
How to use Parameters in CloudWatch Dashboard template
I am trying to create a CloudFormation template to create a CloudWatch dashboard. Following is the template code -
Parameters:
MyEnvironment:
Type: String
Default: "do"
...
4
votes
3
answers
4k
views
Fn::GetAZs + Fn::Select not co-operating
So I have this CloudFormation resource in my networking template:
Resources:
...
PubSubnetAz2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref Vpc
...
4
votes
1
answer
3k
views
Loading CloudFormation YAML using Python
I've got a set of YAML AWS Cloud Formation Templates that I've recently converted from JSON.
When using JSON I was able to load these templates and transform them using jinja to generate some ...
4
votes
2
answers
3k
views
AWS CloudFormation : attribute PathPart must be a readonly property
I am trying to describe my resources on an AWS CloudFormation template. I'm trying to insert in the template the permissions needed by the APIGateway to invoke a Lambda function.
Through the ...
4
votes
1
answer
1k
views
How use Fn::Include and Fn::Sub together?
Consider this code:
MyStateMachine:
Type: "AWS::StepFunctions::StateMachine"
Properties:
StateMachineName: MyStateMachine
DefinitionString:
Fn::Sub:
...
4
votes
1
answer
389
views
Can't return integer from Conditional function in cloud formation yaml
I am writing a cloudformation serverless yaml for a lambda function. I need a conditional parameter reservedConcurrency to be 100 if IsProduction is true, 20 if false. But error happens when I deploy ...
4
votes
1
answer
565
views
AWS CloudFormation for State machine definition: null is not allowed
The AWS CloudFormation supports YAML for state machine defintion, but my CloudFormation cannot deployed if it contains null values in YAML documents.
On the other hand, the ResultPath must be null to ...
3
votes
2
answers
1k
views
Creating a t2 instance with CreditSpecification in Cloudformation
I am trying to launch an AWS EC2 instance using the t2 unlimited burst cpu option in CloudFormation:
AWSTemplateFormatVersion: 2010-09-09
Resources:
EC2I1U4EQ:
Type: 'AWS::EC2::Instance'
...
3
votes
1
answer
13k
views
AWS CloudFormation YAML !Or function
Error: "Template validation error: Template format error: Conditions can only be boolean operations on parameters and other conditions"
Working JSON conditions block:
"Conditions" : {
"...
3
votes
4
answers
2k
views
How to put Tags on API Gateway V2 Resources using a YAML CloudFormation Template
How to put Tags on the following Resources using a CloudFormation Template:
AWS::ApiGatewayV2::Api
AWS::ApiGatewayV2::DomainName
AWS::ApiGatewayV2::Stage
For a generic AWS::ApiGatewayV2::Api ...
3
votes
1
answer
2k
views
Error while creating changeset - "DependsOn must be a string or list of strings."
I am using cloudformation to deploy my code. In my yml file I ahve this DependsOn attribute for which I am trying to add value as "AppApiv1Stage". I have tried multiple things, everytime it ...
3
votes
2
answers
6k
views
How to use existing VPC in AWS CloudFormation template for new SecurityGroup
I am trying to EC2 instance (new), Security group (new) and VPC(existing). Here is my cloudformation template.
When I run the template in Stack, I got error as *"Value () for parameter groupId is ...
3
votes
1
answer
2k
views
CFn: Use !If to add multiple Principals to a statement
I have the following template defining a IAM policy which is not working:
RoleName: 'ABCRole'
AssumeRolePolicyDocument:
Statement:
- Action: ['sts:AssumeRole']
...