Skip to content

Commit

Permalink
client: Add AWS EC2 instance-life-cycle from metadata to client finge…
Browse files Browse the repository at this point in the history
…rprint (#12371)
  • Loading branch information
hntrmrrs committed Mar 25, 2022
1 parent 7edf188 commit 77bab76
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/12371.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
client: fingerprint AWS instance life cycle option
```
1 change: 1 addition & 0 deletions client/fingerprint/env_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *F
"ami-id": false,
"hostname": true,
"instance-id": true,
"instance-life-cycle": false,
"instance-type": false,
"local-hostname": true,
"local-ipv4": true,
Expand Down
16 changes: 16 additions & 0 deletions client/fingerprint/env_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestEnvAWSFingerprint_aws(t *testing.T) {
"platform.aws.ami-id",
"unique.platform.aws.hostname",
"unique.platform.aws.instance-id",
"platform.aws.instance-life-cycle",
"platform.aws.instance-type",
"unique.platform.aws.local-hostname",
"unique.platform.aws.local-ipv4",
Expand Down Expand Up @@ -334,6 +335,11 @@ var awsStubs = []endpoint{
ContentType: "text/plain",
Body: "i-b3ba3875",
},
{
Uri: "/latest/meta-data/instance-life-cycle",
ContentType: "text/plain",
Body: "on-demand",
},
{
Uri: "/latest/meta-data/instance-type",
ContentType: "text/plain",
Expand Down Expand Up @@ -387,6 +393,11 @@ var unknownInstanceType = []endpoint{
ContentType: "text/plain",
Body: "i-b3ba3875",
},
{
Uri: "/latest/meta-data/instance-life-cycle",
ContentType: "text/plain",
Body: "on-demand",
},
{
Uri: "/latest/meta-data/instance-type",
ContentType: "text/plain",
Expand Down Expand Up @@ -417,6 +428,11 @@ var noNetworkAWSStubs = []endpoint{
ContentType: "text/plain",
Body: "i-b3ba3875",
},
{
Uri: "/latest/meta-data/instance-life-cycle",
ContentType: "text/plain",
Body: "on-demand",
},
{
Uri: "/latest/meta-data/instance-type",
ContentType: "text/plain",
Expand Down
6 changes: 6 additions & 0 deletions website/content/docs/runtime/interpolation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ Below is a table documenting common node properties:
</td>
<td>AMI ID of the client (if on AWS EC2)</td>
</tr>
<tr>
<td>
<code>{'${attr.platform.aws.instance-life-cycle}'}</code>
</td>
<td>Instance lifecycle (e.g. spot, on-demand) of the client (if on AWS EC2)</td>
</tr>
<tr>
<td>
<code>{'${attr.platform.aws.instance-type}'}</code>
Expand Down

0 comments on commit 77bab76

Please sign in to comment.