AWS Cloud Formation Cross Stack

As mentioned in AWS blog https://aws.amazon.com/blogs/aws/aws-cloudformation-update-yaml-cross-stack-references-simplified-substitution/ Many AWS customers use one “system” CloudFormation stack to set up their environment (VPCs, VPC subnets, security groups, IP addresses, and so forth) and several other “application” stacks to populate it (EC2 & RDS instances, message queues, and the like). Until now there was no easy way for the application … Continue reading AWS Cloud Formation Cross Stack

AWS – Attach/Replace IAM role of running instance

https://aws.amazon.com/blogs/security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/ https://aws.amazon.com/blogs/security/new-attach-an-aws-iam-role-to-an-existing-amazon-ec2-instance-by-using-the-aws-cli/ From the above articles from AWS we can now attach/replace IAM role of running instances. The below example is simple scenario to test the same using CF.. Provision EC2 Instance, Create S3 bucket, Create S3 Bucket Policy, Role and Instance Profile. But I am not attaching the instance profile to the EC2 Instance … Continue reading AWS – Attach/Replace IAM role of running instance

Jenkins – AWS – Ansible – Rolling Update of AMI – Part 2

As we have configured Job1 - AMI lets move to Job2 - UpdateCF. The temporary file with the AMI Id should be injected in to Job2 so that it can update cloud formation stack with the new image. Now as we are going to use ansible I've placed the code in GitHub Repo. Now in … Continue reading Jenkins – AWS – Ansible – Rolling Update of AMI – Part 2

Jenkins – AWS – Ansible – Rolling Update of AMI – Part 1

Create/Update AMI of Instances through CF - https://linuxandevops.wordpress.com/2017/06/24/aws-update-ami-through-cf-template/ But this is manual as I need to take a snapshot of EC2 Instance and update CF stack with new AMI. It is time to automate the rolling update of AMI using Jenkins and Ansible. Jenkins install and configuration documented here - https://linuxandevops.wordpress.com/2017/07/10/jenkins-install-and-plugins/ Created two jobs - … Continue reading Jenkins – AWS – Ansible – Rolling Update of AMI – Part 1

AWS – Stop Start Instances with Lambda function based on Cloudwatch

This is my customized solution to stop and start AWS EC2 instances. There is solution from Amazon - AWS EC2 Scheduler: https://s3.amazonaws.com/solutions-reference/ec2-scheduler/latest/ec2-scheduler.pdf Example picked from: https://github.com/sangitaccount/AWS/blob/master/cfn-templates/AWS_EC2_ShutStart.template As mentioned in AWS document - https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/  I wanted to stop my development instances during night ( 11 PM )and start them in the morning ( 10 AM ). ISSUE 1: In the … Continue reading AWS – Stop Start Instances with Lambda function based on Cloudwatch

AWS – Ansible – CF Template Boolean Values Not Accepted

Example picked from : https://github.com/sangitaccount/AWS/blob/master/cfn-templates/AWS_AutoScale_ELB_Notification_Single.template In AWS cloud formation template found that there is no parameter type - Boolean. Check the doc from AWS : https://aws.amazon.com/blogs/devops/using-the-new-cloudformation-parameter-types/ While passing - true or false - ansible failing.. example here shows cloud formation template with launch configuration - "AssociatePublicIpAddress" accepts true or false which is self explanatory. PublicORPrivate: True This … Continue reading AWS – Ansible – CF Template Boolean Values Not Accepted

AWS Autoscale Termination Policy vs Update Policy

Termination policy comes into picture when there is "Scale UP" OR "Scale Down". Ref:http://docs.aws.amazon.com/autoscaling/latest/userguide/as-instance-termination.html#custom-termination-policy Update Policy is when - Launch configuration is updated. For e.g. update AMI through autoscale group rolling. Ref: https://aws.amazon.com/premiumsupport/knowledge-center/auto-scaling-group-rolling-updates/ Short Description The AWS::AutoScaling::AutoScalingGroup resource supports an UpdatePolicy attribute. This is used to define how an Auto Scaling group resource is updated when an update to … Continue reading AWS Autoscale Termination Policy vs Update Policy