Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set tags on instance when using a new Launch Template #89

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

snay2
Copy link
Contributor

@snay2 snay2 commented Aug 4, 2022

Issue #, if available: #87

Description of changes:

Our new code for launching Spot instances with CreateFleet requires using a Launch Template that we create on the fly. That Launch Template did not include a tag specification, so Spot instances created this way would not have the default Simple-EC2 tags (CreatedBy and CreatedTime) or any user-specified tags. This is a difference from launching On-Demand instances with RunInstances, where the tags are currently set correctly.

Testing:

Launched an On-Demand instance and a Spot instance with the new code and verified that they both got the Simple-EC2 tags and my own tags (item 1 below is the Spot instance):

+--------+---------------------+-------------------------------+--------------------------------------------+
| OPTION |      INSTANCE       |            TAG-KEY            |                 TAG-VALUE                  |
+--------+---------------------+-------------------------------+--------------------------------------------+
| 1.     | i-083557c9cd7317938 | CreatedTime                   | 2022-08-04 10:23:44 CDT                    |
|        |                     | myTag                         | myValue                                    |
|        |                     | CreatedBy                     | simple-ec2                                 |
|        |                     | otherTag                      | otherValue                                 |
|        |                     | aws:ec2launchtemplate:version | 1                                          |
|        |                     | aws:ec2:fleet-id              | fleet-bdac60ae-8b9f-693c-0c12-8c084246ae68 |
|        |                     | aws:ec2launchtemplate:id      | lt-02bf7c0436455725c                       |
| 2.     | i-0ab5a266a55f63fb4 | myTag                         | myValue                                    |
|        |                     | CreatedTime                   | 2022-08-04 10:22:13 CDT                    |
|        |                     | CreatedBy                     | simple-ec2                                 |
|        |                     | otherTag                      | otherValue                                 |
+--------+---------------------+-------------------------------+--------------------------------------------+

Note that the Spot instance also has some default tags related to Fleet and Launch Templates; we're leaving those intact.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This includes both Simple-EC2 default tags and user-specified tags. Note
that some default launch template tags are already being included; we
make no effort to remove those.
@snay2 snay2 requested a review from a team as a code owner August 4, 2022 15:31
Copy link

@AustinSiu AustinSiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@brycahta brycahta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtAustin (he can't merge)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants