Can you force a tag on any new EC2 instance when upon creation?

I am very new to AWS and I want to make it so that I can set an alarm on any new EC2 instances that ANYONE makes in the organization. I could do this manually by setting an alarm the moment the EC2 instance is made or maybe during the setup process BUT I don’t want the end user to have to set the alarm.

I want them to setup there instance like normal, but after its created, an alarm is automatically applied because a rule or policy on the user or group that forces an alarm on the EC2 instance.

Does this make sense?

Like I want to have an alarm on a VM based on the user who created the VM. Is that possible?

Look into tools that are made for this.
Terraform can do this when you deploy and cloud custodian can do things after deploy (or created in the console)

Cloud watch event and a small lambda
Or include tag in cloud formation template

Could you use guardrails to just prevent it from happening in the first place ?

Second this. Cloudwatch event + Lambda

Use cloud formation templates for everything

You could also use AWS Config. There’s a managed rule for require-tags which you can apply to your EC2 instance.

Check out AWS policies or the service catalog for creation of resources with requirements like tags

https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_tag-policies.html

https://aws.amazon.com/blogs/apn/enforce-centralized-tag-compliance-using-aws-service-catalog-amazon-dynamodb-aws-lambda-and-amazon-cloudwatch-events/

Yeah this managed rule doesn’t exist in my environment. Any idea why?

Control Tower with guardrails.

There are a number of ways to do this but the best way for anything like this in general is to be using infrastructure as code and your users aren’t clicking anything in to existence but rather using modules you’ve set up to create the resources. Terraform is the most popular way to do this. Cloud formation resources could work too, but less popular for a reason. There are 15 other ways you can do what you want but in any respectable organization infrastructure as code is the base layer to start at. Config, tower, any of these things are just cleaning up mistakes that shouldn’t have happened to begin with by fixing your modules to have the right settings by default. You have bigger problems than an alarm not being automatic it sounds like. There are a dozen or two other policies you need to be enforcing too probably.

What region you’re in?

Can’t remember where I looked tbh. Probably London as most of our stuff is there

It should exist there

Wait - certain managed rules are only available in certain regions? That seems … odd?

What’s the reason for cloud formation to be less popular?

Nothing besides the parent commenter’s bubble….

This doesn’t work. The creation of an EC2 instance and tagging are done with two separate API calls. If you enforce tagging for an EC2 instance to be created, no one will ever be able to create an instance - either manually or via IAC.

No.

Why not?