All Projects → unbounce → aws-name-asg-instances

unbounce / aws-name-asg-instances

Licence: MIT License
Automatically apply Name tags to instances in an ASG based on their custom tags

Projects that are alternatives of or similar to aws-name-asg-instances

terraform-vsphere-single-vm
Deploy single vSphere VM with Terraform - template.
Stars: ✭ 21 (+23.53%)
Mutual labels:  infrastructure
infinity
AWS Spot instances for ML
Stars: ✭ 38 (+123.53%)
Mutual labels:  infrastructure
Red-Baron
Automate creating resilient, disposable, secure and agile infrastructure for Red Teams
Stars: ✭ 326 (+1817.65%)
Mutual labels:  infrastructure
provose
Provose is a new way to manage your Amazon Web Services infrastructure.
Stars: ✭ 27 (+58.82%)
Mutual labels:  infrastructure
punic
Punic is a remote cache CLI built for Carthage and Apple .xcframework
Stars: ✭ 25 (+47.06%)
Mutual labels:  infrastructure
DscWorkshop
Blueprint for a full featured DSC project for Push / Pull with or without CI/CD
Stars: ✭ 151 (+788.24%)
Mutual labels:  infrastructure
Stack-Lifecycle-Deployment
OpenSource self-service infrastructure solution that defines and manages the complete lifecycle of resources used and provisioned into a cloud! It is a terraform UI with rest api for terraform automation
Stars: ✭ 88 (+417.65%)
Mutual labels:  infrastructure
reportfactory
Lightweight infrastructure to handle multiple rmarkdown reports
Stars: ✭ 68 (+300%)
Mutual labels:  infrastructure
MLOS
MLOS is a Data Science powered infrastructure and methodology to democratize and automate Performance Engineering. MLOS enables continuous, instance-based, robust, and trackable systems optimization.
Stars: ✭ 75 (+341.18%)
Mutual labels:  infrastructure
c3
𝗖𝟯 provides compliant AWS CDK components to various security standards.
Stars: ✭ 24 (+41.18%)
Mutual labels:  infrastructure
devops-infra-demo
Growing repository of Infrastructure as Code demos (initially created for DevOps Wall Street)
Stars: ✭ 31 (+82.35%)
Mutual labels:  infrastructure
teuton
Infrastructure test, mainly useful for sysadmin teachers and making contests
Stars: ✭ 22 (+29.41%)
Mutual labels:  infrastructure
tinycore-kernel
TinyCore Linux kernel and module compile scripts. Download pre-built kernels and modules here: https://bintray.com/on-prem/tinycore-kernels/linux
Stars: ✭ 22 (+29.41%)
Mutual labels:  infrastructure
deploykit
A toolkit for creating and managing declarative, self-healing infrastructure.
Stars: ✭ 2,246 (+13111.76%)
Mutual labels:  infrastructure
sre-playground
🎯 A set of Site Reliability Engineering notes & challenges
Stars: ✭ 24 (+41.18%)
Mutual labels:  infrastructure
infrastructure-as-code
anmolnagpal.com/infrastructure-as-code
Stars: ✭ 17 (+0%)
Mutual labels:  infrastructure
jschr.io
The static website generator service behind jschr.io.
Stars: ✭ 70 (+311.76%)
Mutual labels:  infrastructure
infrastructure
Deprecated due to new Gitea.com infra
Stars: ✭ 14 (-17.65%)
Mutual labels:  infrastructure
domain-event-bundle
Library to create the domain layer of your DDD application
Stars: ✭ 14 (-17.65%)
Mutual labels:  infrastructure
planvelo-carte
Observatoire du Plan Vélo
Stars: ✭ 28 (+64.71%)
Mutual labels:  infrastructure

aws-name-asg-instances

Automatically apply Name tags to instances in an ASG based on their custom tags.

Names that appear in the AWS console beside EC2 instances are set by creating a special tag Name. When members of an ASG start, they are not given any names, so often what happens is that instance is allowed to name itself inside of user data. However, if user data fails for any reason, the instance will never name itself and it can be difficult to find the instance's purpose in the AWS console.

The issue with an instance naming itself is that the instance profile (and underlying IAM role) provides the instance with the ec2:CreateTags permission, which cannot have a scoped Resource declaration. This violates least privilege and provides the instance with the ability to create (and overwrite) tags on any instance in the same AWS account.

This project creates a CloudWatch Event rule that watches for AutoScaling events, specifically the successful launch of new EC2 instances, and names them based on their tags. Thus, only the Lambda function that backs the CloudWatch Event rule has the abiility to name EC2 instances, and only in a specific format.

Costs

The resources created under this CloudFormation template will cost either very little or nothing. The only element that costs anything is the Lambda function, and Amazon has a generous free tier that should cover just about everyone's use case for this tool, making it free to run.

Naming Format

The instances are named based on the following convention:

<project>-<environment>-<instance_id>

The tags project and environment must be available on the instance and given a non-empty string value. The instance_id is already known by the auto-scaling group during launch, so you do not need to provide it.

The instance_id is stripped of its i- prefix, leaving only the unique ID.

The resulting name is then limited to 255 characters, as that is the limit of tag values.

An example of this is, using a project donny and environment staging is:

donny-staging-029d0202d1a

Project Requirements

  • Ansible (optional, but useful)

  • Amazon Web Services account

  • Permissions to create AWS resources:

    Specifically: CloudFormation, CloudWatch Events, Lambda, IAM roles

Launching the Stack

The stack must be launched in any region where auto-scaling groups are used and you want to name its members. However, CloudWatch Event rules may not be available in every region, so the following Ansible playbook ensures that the stack is launched only in the regions where all AWS services are supported.

ansible-playbook -i localhost.inventory -e 'stack_env=production' create-stack.yml

License

tl;dr MIT license.

Please read LICENSE to view the license for this project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].