All Questions
Tagged with aws-cloudformation amazon-ec2
781
questions
67
votes
1
answer
30k
views
Name an EC2 Instance in the CloudFormation template?
I have a template that works and generates a stack but I cannot find a property to set or something else that allows me to give a Name to the EC2 Instance I have created. When it is generated the Name ...
49
votes
9
answers
28k
views
Cloudwatch failedinvocation error no logs available [closed]
I have set up a Cloudwatch rule event where an ECS task definition is started when a previous task definition is completed.
I can see the event triggers the task definition however it fails.
The ...
41
votes
3
answers
33k
views
NLB Target Group health checks are out of control
I have a Network Load Balancer and an associated Target Group that is configured to do health checks on the EC2 instances. The problem is that I am seeing a very high number of health check requests; ...
37
votes
4
answers
28k
views
Create AMI image as part of a cloudformation stack
I want to create an EC2 cloudformation stack which basically can be described in the following steps:
1.- Launch instance
2.- Provision the instance
3.- Stop the instance and create an AMI image ...
36
votes
3
answers
45k
views
How to specify all ports in Security group - CloudFormation
I have my CloudFormation script like this now:
"SecurityGroupIngress" : [{
"IpProtocol" : "tcp",
"FromPort" : "0",
"ToPort" : "65535",
"CidrIp" : "0.0.0.0/0"
}]
and ...
31
votes
5
answers
35k
views
How to create variable number of EC2 instance resources in Cloudformation template?
How to create variable number of EC2 instance resources in Cloudformation template, according to a template parameter?
The EC2 API and management tools allow launching multiple instances of the same ...
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: ...
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 ...
18
votes
1
answer
6k
views
aws CloudFormation AWS::EC2::Instance BlockDeviceMappings and Volumes
I am sort of confused about two AWS::EC2::Instance properties:
BlockDeviceMappings and Volumes.
I have read documentation a number of times but still don't really understand the difference.
Here is ...
17
votes
4
answers
24k
views
How to deny all outbound traffic from an AWS EC2 Instance using a Security Group?
I am trying to set an AWS Security Group egress rule which blocks all outbound traffic. It has been known that by default, security groups allow all outbound traffic.
I am using AWS CloudFormation ...
17
votes
4
answers
44k
views
How do I force a CloudFormation stack to update when the parameter is updated?
I am running a AWS CloudFormation stack that takes in some parameters and launches EC2 instances along with other AWS resources. The parameters are fed into the user data of the EC2 instance and based ...
17
votes
2
answers
16k
views
How to attach and mount volumes to an EC2 instance using CloudFormation
I can't find a way to attach and mount volumes using cloudformation.
I can attach a volume using VolumeAttachment; however, when I do lsblk after my EC2 instance is in running state, I see this ...
17
votes
4
answers
7k
views
Is there a way to tag a root volume when initializing from the cloudformation template?
I am creating an instance through the cloud formation script.
The only way I found to attach an OS partition was through "BlockDeviceMappings" property. (I've tried to use "Volumes" property before, ...
16
votes
3
answers
26k
views
Security Group and Subnet Belongs to different networks
I am creating a basic AWS CloudFormation Template with one VPC, 3 Security Group and 5 EC2 Instances my security group looks something like this -
{
"WebApplicationServerSG": {
"Type": "AWS::...
16
votes
6
answers
16k
views
Add an unknown-sized list of security groups to an EC2 instance
We have a CloudFormation template that creates an EC2 instance and a security group (among many other resources), but we need to be able to add some additional pre-existing security groups to that ...
16
votes
2
answers
13k
views
Cloudformation template error - Template validation error: Template format error: Every Mappings member Type must be a map
I have a cloudformation template.
It should create an EC2 instance, change the Adminstrator password and rename the server.
I am passing couple of parameters to the stack template. When I run it, ...
15
votes
5
answers
6k
views
How to name an Auto Scaling Group in a CloudFormation template?
I have a CloudFormation template that creates an auto scaling group (among other things). How can I give the auto scaling group a name in the template?
The AWS docs do not mention anything (http://...
14
votes
2
answers
10k
views
Non-Windows instances with a virtualization type of 'hvm' are currently not supported for this instance type : [AWS Cloudformation]
I am trying to create a an t2.micro ec2 instance with amazon linux as os using cloudformation . Following is the json file (parts that matter).
"FileName" :{
"Type" : "String",
"...
14
votes
2
answers
8k
views
The DB instance and EC2 security group are in different VPCs, cloudFormation error
I want to automate the process of creating RDS. I would like to create RDS Aurora.
When deploying the application, stack cloudFormation is validated and I have an error:
An error occurred: ...
14
votes
2
answers
7k
views
cfn-init for cloudformation launchtemplate
How do you use cfn-init within a LaunchTemplate? This is for EC2 instances, in an autoscaling group, for an ECS cluster.
Where does the Metadata section for the instance go and what is the --resource ...
13
votes
1
answer
7k
views
Increase the root device size in cloudformation autoscaling group
I am trying to increase the hard disk space on my ebs backed ec2 instance from my cloudformation AutoScaling::LaunchConfiguration. Initially the root device starts with 8GB. I'd like to increase ...
13
votes
1
answer
3k
views
Force EC2 Instance Replacement When Updating UserData in CloudFormation
I'm using the UserData field in a CloudFormation template to install software on the instance. When I update the UserData I would like CloudFormation to replace the instance. However, UserData is not ...
12
votes
3
answers
7k
views
How to automate EBS encryption with Elastic Beanstalk
I am looking to encrypt my root EBS volumes for new EC2 environments that I create. I know that I can do this from the AWS console and from CloudFormation, but would like to be able to do so via an ...
12
votes
3
answers
16k
views
AWS Cloudformation: How to reuse bash script placed in user-data parameter when creating EC2?
In Cloudformation I have two stacks (one nested).
Nested stack "ec2-setup":
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Parameters" : {
// (...) some parameters here
"userData" : {
...
12
votes
2
answers
27k
views
AWS CloudFormation stack fails with error Received 0 SUCCESS signal(s) out of 1
My AWS CloudFormation template fails with the error:
Received 0 SUCCESS signal(s) out of 1. Unable to satisfy 100%
MinSuccessfulInstancesPercent requirement
I'm thinking my WaitConditionHandles ...
12
votes
2
answers
7k
views
Can IAM role temporary credentials be used in cloudformation templates?
I'm building a stack that needs access to a private S3 bucket to download the most current version of my application. I'm using IAM roles, a relatively new AWS feature that allows EC2 instances to be ...
10
votes
3
answers
16k
views
How to get cfnoutputs of AWS stack to a file using AWS-CDK
I want to store the Cfnoutputs in AWS-CDK to a file(Python).
Below is the code to show Public IP on console.
my_ip = core.CfnOutput(
scope=self,
id="PublicIp",
value=my_ec2....
10
votes
2
answers
13k
views
AWS CloudFormation: How to get subnet list from VPC?
In CloudFormation, I'm creating a VPC, two EC2 instances, and an Elasticache in front of them. In the template, I'm trying to add the elasticache to the vpc. The problem's happening in creating the ...
10
votes
3
answers
4k
views
Is there a way to get a volume unmounted when I call CloudFormation delete-stack?
I am using CloudFormation to create my environment. Part of the stack includes creating a volume from a snapshot, associating it with an EC2 instance, and then mounting it.
"Resources" : {
"...
10
votes
3
answers
39k
views
At least one Resources member must be defined ...error in cloud formation ec2
I tried other templates from the net but still getting the same error. Error
message: Template contains errors.: Template format error: At least one Resources member must be defined.
{
"...
10
votes
1
answer
7k
views
How can I use AssumeRole from another AWS account in a CloudFormation template?
I am trying to work out the logic flow for an AWS CloudFormation template that will assume an IAM role that can pull files from a S3 bucket in another AWS account.
What I have so far is:
accountA ...
9
votes
2
answers
9k
views
How to create Elastic IP association with an EC2 instance using AWS CDK?
In AWS CDK, I have an EC2 instance and Elastic IP created as follows:
// EC2 Instance
let ec2Instance = new ec2.Instance(this, "EC2Instance", {
instanceType: ec2.InstanceType.of(...
9
votes
1
answer
4k
views
How to use CloudFormation to edit a VPC's default network ACL?
If I declare the following resource in a CloudFormation template,
"CoolVpc": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.10.0.0/16",
"Tags": [
{"Key": "Name", "Value"...
8
votes
1
answer
9k
views
Receiving a validation error detected: Value '[AWS:RDS::DBInstance]' at 'typeNameList' failed
I am trying to create an RDS server running MySQL database and receiving the following error:
1 validation error detected: Value '[AWS:RDS::DBInstance]' at 'typeNameList' failed to satisfy constraint: ...
8
votes
1
answer
4k
views
How do I assign an EC2 instance to a fixed IP address within a subnet?
I'm using CloudFormation to define a subnet and EC2 instance. I want to allocate a particular private IP address to an EC2 instance and have attempted to do so using the resource definitions such as ...
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 ...
8
votes
3
answers
3k
views
How to configure "Instance Protection" over CloudFormation in AWS?
I need to set an "Instance Protection" property for the instances in my Auto Scaling Group using a CloudFormation template.
I normally do it in my AWS console like this: EC2 -> Auto Scaling Groups
...
8
votes
2
answers
4k
views
Does AWS cfn-init need a Profile/Role for DescribeStackResource?
From this page:
To use the AWS CloudFormation bootstrap features, you need to provide AWS credentials to the
bootstrap scripts. We strongly recommend that you assign an IAM role to on the EC2 ...
8
votes
2
answers
5k
views
Ubuntu: Could not enable service cfn-hup
I am using a custom Ubuntu AMI on CloudFormation template and I am getting an error which says CREATE_FAILED AWS::AutoScaling::AutoScalingGroup WebServerGroup Received 0 SUCCESS signal(s) out of 1....
8
votes
2
answers
10k
views
How to create an Amazon VPC using AWS CloudFormation?
I am currently using AWS CloudFormation for my application. Right now I am able to auto scale the instances. Now, I want to put every thing on an Amazon VPC. Can we create a VPC using CloudFormation? ...
8
votes
2
answers
4k
views
How do I pass UserData to a Beanstalk instance with CloudFormation
I need the application server, which is beanstalk instances, to do some actions upon startup and I thought of running a bash script passed to the instance with the UserData property which is available ...
8
votes
3
answers
3k
views
CloudFormation Transform::Include parameters
I want to use AWS macro Transform::Include with some dynamic parameters for my file.
Resources:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
TestMacroVariable:
Default: ...
7
votes
4
answers
19k
views
How to assign EIP to Autoscaling Group of VPC in Cloudformation template
I want to assign one of my reserved Elastic IP's(ec2 classic ip) to Autoscaling group in VPC. Using AWS Cli I moved ip to vpc:
$ aws ec2 move-address-to-vpc --public-ip 23.23.23.23
And saw in aws ...
7
votes
2
answers
9k
views
CloudFormation SecurityGroup Circular Reference
I am working with two simple web apps that need to talk to each other. Within AWS CloudFormation I have a template that creates an EC2 instance and installs both applications on the same server (...
7
votes
2
answers
36k
views
Value of property SecurityGroupIds must be of type List of String error while updating stack
I am getting ROLLBACK_COMPLETE while try to updating a stack using the following code. Under events, I am not getting an error as "Value of property SecurityGroupIds must be of type List of String"....
7
votes
4
answers
12k
views
Can we dynamically create Keypair through AWS Cloudformation and copy the .PEM file to EC2 Linux instance
My requirement is to create an EC2 instance which will have the Keypair created dynamically from the same Cloudformation template.As of now,I am creating the KeyPair from AWS console and assigning it ...
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 ...
7
votes
2
answers
16k
views
How to create a EC2 instance from snapshot in cloudformation?
I'd like to specify the snapshot id which would be used to create a root device image for a EC2 instance created with cloudformation. How do I do that?
I could only find a way to make volume from a ...
7
votes
1
answer
9k
views
Reusing AWS::CloudFormation::Init (and userdata?) for multiple instances
Is it possible to reuse the same bootstrapping config from AWS::CloudFormation::Init (and/or userdata) for multiple EC2::Instances in a template?
I need to set the content of 3 files and then run 3 ...
7
votes
3
answers
5k
views
Auto scaling using cloud formation according to Request count
We are using cloud formation for auto scaling according based upon the load balancer RequestCount metric. Currently we scale up an instance if the request is increased to 1500 for 1 minute (each ...