All Questions
Tagged with aws-cloudformation aws-cli
150
questions
92
votes
5
answers
56k
views
Getting Outputs from aws cloudformation describe-stacks
I am using the below to get the stack information I want via AWS Cli:
aws cloudformation --region ap-southeast-2 describe-stacks --stack-name mystack
It's returning result OK:
{
"Stacks": [
...
63
votes
4
answers
74k
views
AWS CLI S3: copying file locally using the terminal : fatal error: An error occurred (404) when calling the HeadObject operation
I'm trying to copy files locally from s3 bucket. I can get the list of files on my bucket:
aws s3 ls s3://myBucket/myDirectory/todaysFiles/
But when I try to copy the files locally:
aws s3 cp s3://...
51
votes
3
answers
19k
views
AWS CloudFormation create-stack vs deploy
Can someone clearly explain to me difference and precedence between AWS CLI Cloudformation create-stack and deploy commands? For me it seems like they do same thing and deploy resources.
Why when you ...
15
votes
2
answers
36k
views
Passing multiple parameters from external file to cloudformation template and using values with ref
I am getting following error when trying to create a cloudformation stack using below cli command.
aws cloudformation create-stack --stack-name subodh-local-stack --template-url s3URL/template.json --...
11
votes
1
answer
8k
views
Cloudformation template validate
According the aws validate-template, I did the test to validate same template from URL and local file.
But I got different output.
Test from URL directly:
$ aws cloudformation validate-template --...
11
votes
1
answer
11k
views
How to describe Security Groups for a VPC?
Is there a way to describe a Security Group in a specific VPC?
Here is what I am trying to run :
aws ec2 describe-security-groups --group-name "<group-name>" --filter Name=vpc-id,Values=<my-...
10
votes
2
answers
8k
views
Update cloudformation stack from aws cli with SAM transform
When attempting to update a cloudformation stack in the aws cli:
aws --profile dev cloudformation update-stack --stack-name mystackname --template-body file://events-list.yaml
I get the following ...
9
votes
1
answer
6k
views
Using troposphere for cloud formation, how do I add "propagate at launch" to tags
I'm using the python module troposphere to generate tags in my cloud formation template. The current script generates:
"Tags": [{"Key":"Name", "Value":"MyTagName"},
{"Key":"...
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
4k
views
AWS CLI vs Console and CloudFormation stacks
Is there any known downside to creating resources on aws through the CLI? Is it more reliable/easier/error prone/largely accepted/recommended to use one method over the other? While setting up ...
8
votes
2
answers
6k
views
AWS CLI list only the name of current running cloudformation stacks?
I'm building up to a larger AWS CLI job but one of the building blocks is stumping me;
How do I get a list of just the names of every currently running AWS Cloudformation stack?
I can list the ...
8
votes
4
answers
6k
views
Error: The provided credentials do not have permission to create the service-linked role for EC2 Spot Instances
I'm running into an error when creating a spot fleet request through cloudformation. The request is created but I'm getting the error mentioned in the title when the fleet attempts to request an ...
7
votes
2
answers
4k
views
Aws cli cloudformation error seen on passing parameter value of type CommaDelimitedList
I am seeing an invalid-type error for a CommaDelimitedList parameter value. The CF runs without any errors from the console.
AWS CLI command:
aws cloudformation create-stack --stack-name ...
7
votes
2
answers
6k
views
AWS CloudFormation: Nested Sub with Dynamic References using {{resolve}} causes error and doesn't execute resolve to get value from Parameter Store
I am trying to use AWS CloudFormation Template to create an EC2 Instance with some userdata generated using dynamic references and cross-stack reference in the template . There is a parameter stored ...
6
votes
2
answers
4k
views
Drawing an image from a cloudformation template
Is the any drawing / export tool that I can use to turn a cloudformation template into a diagram.
In need to export my cloudformation stack into an image, or a graphviz file.
Regards,
6
votes
1
answer
2k
views
Use AWS CLI to import existing resources into CloudFormation
I have a collection of CloudFormation templates that I'm using to create new resources but I also have a small percentage of AWS resources that were created outside of CF that I now want to import ...
6
votes
3
answers
5k
views
How can I instruct an AWS CloudFormation template to create resources in a specific region?
I am new to CloudFormation templates. I have basic template in yaml that creates an EC2 Instance. Every time I create a stack and use this template, the EC2 Instance is ALWAYS created on US East N. ...
6
votes
1
answer
2k
views
Get ARNs of all resources in Cloudformation Stack
What is the easiest way to get the ARN of each resource created by Cloudformation?
I'm trying to find an easy way to do this, so that I can collect this information and send it to an external ...
6
votes
1
answer
9k
views
Delete AWS Cloud formation stack with resources created by it
Based on this page I can do:
aws cloudformation delete-stack \
--stack-name my-stack
It says I can attach the command:
[--retain-resources <value>]
Does that mean that if I don't specify ...
6
votes
1
answer
4k
views
Correct CloudFormation For Route53 RecordSet to API Gateway
I'm trying to deploy a CloudFormation template (through AWS CLI) that contains DynamoDB and some Lambdas served through API Gateway. The following is the template:
Resources:
UTableArticle:
...
5
votes
2
answers
3k
views
How to pass a role to cli command "aws cloudformation deploy" or "sam deploy"?
I am creating a cloudformation stack using a SAM template and the CLI. I have successfully done this using an account that gets all the required permissions from policies directly attached to it. It's ...
5
votes
1
answer
6k
views
Cross account S3 access through CloudFormation CLi
I am trying to create a CloudFormation Stack using the AWS CLI by running the following command:
aws cloudformation create-stack --debug --stack-name ${stackName} --template-url ${s3TemplatePath} --...
5
votes
4
answers
7k
views
How to wait until an AWS CloudFormation stack creation or update is completed in bash?
I have a use-case where my bash script needs to wait until AWS CloudFormation completes Creating or Updating the stacks.
I found the following commands can be used to do so:
aws cloudformation wait ...
4
votes
4
answers
8k
views
Is there a way to specify only changed parameters using aws cloudformation update stack and avoid explicit UsePreviousValue for unchanged parameters?
I am trying to write a generic script in AWS Cloudformation CLI that will update the stacks' parameter AMI to a new value while leaving the rest of the parameters as is.
So far, I tried doing this ...
4
votes
2
answers
2k
views
How can I retry a AWS CloudFormation update if an update is already happening?
Trying to implement CI, every commit will trigger a CFN update. How can I check if an update is happening and force my script to wait or schedule some retry at a future time?
I see there's a describe-...
4
votes
1
answer
3k
views
How to list only the EC2 instances in a given CloudFormation stack?
What can I use for $QUERY in the command below that meets the following criteria:
aws ec2 describe-instances --query $QUERY
Only prints instances with an aws:cloudformation:stack-name tag equal to ...
4
votes
5
answers
4k
views
How do you add spaces for aws cloudformation deploy --parameter-overrides and/or --tags?
I am trying to get spaces into the tags parameter for the aws cli and it works if I hardcode it but not if I use bash variables. What is going on and how do I fix it?
This works with out spaces:
aws ...
4
votes
1
answer
262
views
How to parse free tier RHEL AMI ID on AWS with Cloudformation?
I've started to write some simple Cloudformation scripts to provision infrastructure. It's waking up 4 nodes (1 Ansible Headnode - 3 Slave). All of the nodes images are free tier RHEL images on AWS. ...
3
votes
3
answers
6k
views
How to encrypt environment variables for Lambda via CLI?
When creating a Lambda function, it's not very hard to encrypt an environment variable via the GUI console. I just enter the key value pairs, then open the encryption helper and enter the ARN of my ...
3
votes
2
answers
3k
views
How to deploy SAM template using boto3
I am trying to deploy
https://s3.amazonaws.com/serverless-chatbot-code/chatbot.yaml
using boto3 library function create_stack but getting an error
"CreateStack cannot be used with templates ...
3
votes
1
answer
725
views
How to determine what CloudFormation stack an AWS resource belongs to using AWS CLI?
I have an EC2 instance and I want to know which cloud formation stack it belongs to using AWS CLI.
To do this using boto in python, refer How to determine what CloudFormation stack an AWS resource ...
3
votes
2
answers
958
views
How to generate AWS CloudFormation using existing environments
I have existing AWS configuration
Api getway
RDS
EBS
EC2
Cognito
S3
aws Lambda
Now I want to create different environment like Dev, QA, UAT and Prod
Is there any option available in AWS or Open ...
3
votes
1
answer
1k
views
AWS - Cannot find a Cloudfront stack
I'm facing a pretty weird problem using AWS CLI. I created a new IAM user from my main profile and I gave this user AdministratorAccess in order to allow this user to create AWS resources using a ...
3
votes
2
answers
2k
views
Break cloudformation file into smaller scripts
I have large cloudformation json file which I used to create new vpc, subnets, ec2 instance.
Basically looking into breaking file into multiple small file for easy maintenance.
How do I create
a) ...
3
votes
1
answer
764
views
What is the proper way to describe resources of a nested CloudFormation stack?
We have a CloudFormation script which has four nested stacks. I'm trying to describe the resources of those nested stacks. However, when I describe-stack-resources with the physical ID of one of the ...
3
votes
3
answers
5k
views
In `aws cloudformation deploy --parameter-overrides`, how to pass multiple values to `List<AWS::EC2::Subnet::ID>` parameter?
I am using this CloudFormation template
The List parameter I'm trying to pass values to is:
"Subnets" : {
"Type" : "List<AWS::EC2::Subnet::Id>",
"...
3
votes
1
answer
7k
views
Error parsing parameter '--parameters': Expected: '=', received: 'P'
I am working with aws cli cloudformation. While using the JSON parameters file along with yml template, I keep getting the error. I tried using create stack update stack as well as the change set.
...
3
votes
1
answer
2k
views
Running cloudformation template fails when using custom Transform in CodeBuild
One of my build steps runs a cloudformation template which has a custom transform. The transform is available in us-east-1 which is the same region in which code build is running. This same ...
3
votes
1
answer
1k
views
using Cloudformation ref with awscli in userData
"aws ec2 create-tags --resources xxxxxx --tags Key=Team,Value=everybody --region { \"Ref\" : \"region\" } --out text\n"
The above line/command I am using in my Cloudformation userData, It is not ...
2
votes
2
answers
2k
views
aws cloudformation list-stacks gives me duplicate stacks?
I run this to get a list of my CF stacks:
aws cloudformation list-stacks --region us-east-1
I seem to be getting multiple results for the same stacks. I seems like its returning every version of ...
2
votes
1
answer
892
views
The AWS stack removes RDS with the final snapshot
Some time ago, while deleting a stack, RDS was also deleted without leaving a final snapshot, now when RDS is deleted and a manual snapshot is created that is not deleted. What could be the reason?
I ...
2
votes
2
answers
3k
views
AWS Cloudformation - reverse engineer an existing resource
Initially a while back created a cloudformation template to create multiple services on a given cluster, setup a aurora rds, redis and a load balancer.
The template was broken so i had to do various ...
2
votes
1
answer
424
views
Difference between --parameter-overrides and --tags
I am having a hard time understanding the difference between --parameter-overrides and --tags when deploying an AWS stack using CloudFormation.
I tried to read through the documentation but I still do ...
2
votes
1
answer
1k
views
aws-cdk aws-cli cloudformation generating extra characters in arn
I am using the aws-cdk to create cloudformation templates, really just SNS and SQS. My problem is that the names of the generated Topics and Queues are not what I see in the yaml file.
Here is the ...
2
votes
1
answer
2k
views
aws cloudformation package command not found on aws-cli/1.10.56
I am a AWS noob and have been task to investigate serverless deployment.
I am following the examples in:
http://docs.aws.amazon.com/lambda/latest/dg/serverless-deploy-wt.html
as well as
http://docs....
2
votes
1
answer
535
views
aws cli cloudformation lambda invalidinput error
I am trying to modify an example of a lambda function in java using this example:
https://github.com/awsdocs/aws-lambda-developer-guide/tree/main/sample-apps/s3-java
But in the process, I started ...
2
votes
1
answer
695
views
Restore RDS Snapshot from console or CLI is way faster than cloudformation?
I am writing some automation to create a duplicate of the of my AWS production environment for devs and QA to test with. I am using a bash script calling a AWS cli with AWS Cloudformation templates.
...
2
votes
1
answer
8k
views
aws command not found error even after installing aws cli on jenkins windows slave when running a jenkins job
I have installed AWS CLI on my windows slave in Jenkins. To verify the same, I run the following command in the command line of the windows machine and get this as the output
C:> aws --version
aws-...
2
votes
1
answer
3k
views
aws cloudformation describe-stack-resources query by LogicalResourceId
I am attempt to retrieve a stack PhysicalResourceId using the aws command line.
$ aws cloudformation describe-stack-resources \
--stack-name test-app-prometheus \
--query 'StackResources[?...
2
votes
1
answer
333
views
Is it possible to use cloud formation to deploy a Cloud9 ide on an EC2 image that is not obsolete?
Apparently Cloud9 out of the box is being shipped on an essentially obsolete EC2 instance, as it does not have a current, recent, or viable instance of the aws cli.
$ aws --version
aws-cli/1.19.112 ...