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

Add VpcId to TMDE Task Responses #3288

Merged
merged 7 commits into from
Sep 7, 2022
Merged

Add VpcId to TMDE Task Responses #3288

merged 7 commits into from
Sep 7, 2022

Conversation

amogh09
Copy link
Contributor

@amogh09 amogh09 commented Jul 6, 2022

Summary

This change is to enhance the TaskResponse returned by Task Metadata Endpoint to include VPC ID. This change does not apply to ECS Anywhere instances, so no VPC ID would be returned by Task Metadata Endpoint on ECS Anywhere instances.

Implementation details

For agent instances with TaskENIEnabled setting set to true

Agent loads the VPC ID of the container instance by querying EC2 Instance Metadata Service (IMDS). So, for TMDE the VPC ID of the container instance is already available in ecsAgent type.

For agent instances with TaskENIEnabled setting set to false

Currently the agent does not load the VPC ID of the container instance in this case. This PR includes changes to make the agent load VPC ID (and mac and subnets) of the container instance if the container instance is not external. Doing so shouldn't have any side-effects because these values are not used to drive any logic.

Changes under this PR add some piping to forward the VPC ID value from ecsAgent type to Task Metadata Endpoint handlers and change the handlers to include the VPC ID value in all task responses. TaskResponse type definition is updated to include a new VPCID field.

Testing

Deployed changed agent source to a test EC2 instance, ran test tasks with awsvpc, bridge, and host network modes, and verified that VpcId field is populated in task responses for all cases.

Deployed changed agent to a test ECS Anywhere instance, ran a test task with host network mode, and verified that VpcId field is not populated and that a successful Task Response is returned.

Updated MACIS TMDE functional tests for Linux and Windows and ran them against the agent artifacts for this PR for EC2 Linux and Windows, and ECS-A Linux and Windows platforms.

Updated existing Task Metadata Endpoint unit tests to include VpcId.

New tests cover the changes: Updated existing tests

Description for the changelog

VpcId field will be present in task responses from Task Metadata Endpoint for EC2 instances. ECS Anywhere instances are not affected.

Licensing

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

agent/handlers/task_server_setup.go Outdated Show resolved Hide resolved
Realmonia
Realmonia previously approved these changes Jul 11, 2022
singholt
singholt previously approved these changes Jul 18, 2022
Realmonia
Realmonia previously approved these changes Jul 28, 2022
Copy link
Contributor

@Realmonia Realmonia left a comment

Choose a reason for hiding this comment

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

Please squash changes before merging.

singholt
singholt previously approved these changes Jul 28, 2022
@amogh09
Copy link
Contributor Author

amogh09 commented Aug 15, 2022

Only v4 endpoint's response may be changed. Older versions are considered immutable. Need to limit this change to v4.

@amogh09 amogh09 merged commit 3ad38be into aws:dev Sep 7, 2022
@amogh09 amogh09 deleted the tmde-add-vpc branch September 7, 2022 23:10
@chienhanlin chienhanlin mentioned this pull request Sep 12, 2022
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.

4 participants