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

chore(ecs-patterns): ExecuteCommand support in ApplicationLoadBalancedFargateService #15497

Closed
wants to merge 12 commits into from

Conversation

mzizzi
Copy link

@mzizzi mzizzi commented Jul 11, 2021

Addresses #15197 by adding support for enabling ExecuteCommand for Services created with ApplicationLoadBalancedFargateService.


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

@gitpod-io
Copy link

gitpod-io bot commented Jul 11, 2021

@awsiv
Copy link

awsiv commented Jul 21, 2021

@mzizzi thanks for this - I was waiting for this functionality as well :)

Also - looks like this needs to be rebased against main again

@danwiltshire
Copy link
Contributor

Awesome stuff.

Roughly when would this be rolled into a release?


// THEN - stack contains a service with execute-command enabled
expect(stack).to(haveResourceLike('AWS::ECS::Service', {
EnableExecuteCommand: ABSENT,
Copy link
Contributor

@paragbhingre paragbhingre Jul 29, 2021

Choose a reason for hiding this comment

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

Does expected default value is ABSENT? or we do we expect false as a default value?

Copy link
Author

@mzizzi mzizzi Sep 2, 2021

Choose a reason for hiding this comment

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

Hey sorry for the late response. As implemented the default for the interface is to leave that property undefined as an optional with readonly enableExecuteCommand?: boolean;

If you're arguing that we shouldn't be allowed to omit that property and force a true/false then I can make those changes. Cloudformation looks to be happy with either true/false or omitting the property altogether.

Unrelated: I'll fix the copy/pasta comments that are incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need either of the omitted or false tests. The ABSENT test asserts whether the prop is undefined or not set (a check not necessary in our case) and the false test below essentially checks if the enableExecuteCommand is set correctly and so does the true test. It would be great if you could remove both these unit tests.

Copy link
Author

Choose a reason for hiding this comment

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

Hey, thanks for the review!

I don't think we need either of the omitted or false tests. The ABSENT test asserts whether the prop is undefined or not set (a check not necessary in our case)

Why wouldn't it be necessary to test ABSENT behavior? It's a valid config and what most (all) people will be using prior to this PR being merged. It's a good check of back compatibility and that the underlying templates that get synthed aren't changing for people that omit this option.

and the false test below essentially checks if the enableExecuteCommand is set correctly and so does the true test. It would be great if you could remove both these unit tests.

I'd argue that we should be testing to ensure that the proper value is getting set all of the way through for each possible input and not just the happy (true) path. These act as regression tests for each of possible configs related to this feature. If the guts of the implementation change and break things then these tests will fail.

Copy link
Contributor

@upparekh upparekh Oct 11, 2021

Choose a reason for hiding this comment

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

The purpose of the ABSENT assertion is not to check for backwards compatibility. The new test suite will run only against the updated construct. If there is a field that explicitly needs to be false/ undefined for a certain configuration of props then we would use the ABSENT assertion.

You’re right, we should not only check for happy paths. enableExecuteCommand for this L3 construct is only an input property (not a class attribute which can be modified). It will set the corresponding L2 property to what is provided as input and any other testing is taken care by the L2. Thus, we should be good with using the true literal.

@camharris
Copy link

@mzizzi are you sure this will handle adjusting the iam roles for ssmmessages?

@upparekh upparekh added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 18, 2021
@upparekh upparekh changed the title feat(ecs-patterns): ExecuteCommand support in ApplicationLoadBalancedFargateService chore(ecs-patterns): ExecuteCommand support in ApplicationLoadBalancedFargateService Aug 18, 2021
@mzizzi
Copy link
Author

mzizzi commented Sep 3, 2021

@mzizzi are you sure this will handle adjusting the iam roles for ssmmessages?

It should ultimately be handled it in the same way that it is handled here:

private enableExecuteCommand() {

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 41c2a21
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@upparekh upparekh left a comment

Choose a reason for hiding this comment

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

Hi @mzizzi , the PR looks good but I have two suggestions!


// THEN - stack contains a service with execute-command enabled
expect(stack).to(haveResourceLike('AWS::ECS::Service', {
EnableExecuteCommand: ABSENT,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need either of the omitted or false tests. The ABSENT test asserts whether the prop is undefined or not set (a check not necessary in our case) and the false test below essentially checks if the enableExecuteCommand is set correctly and so does the true test. It would be great if you could remove both these unit tests.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 21, 2021
@@ -174,6 +181,7 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc
circuitBreaker: props.circuitBreaker,
securityGroups: props.securityGroups,
vpcSubnets: props.taskSubnets,
enableExecuteCommand: props.enableExecuteCommand,
Copy link
Contributor

Choose a reason for hiding this comment

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

why scope it that small and not patch it into all base classes of the patterns (i.e. application-load-balanced-service-base.ts, application-multiple-target-groups-service-base.ts, network-load-balanced-service-base.ts, network-multiple-target-groups-service-base.ts, queue-processing-service-base.ts, scheduled-task-base.ts)

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC ECS Exec works on Fargate and EC2, so I would reccomend patching the base classes to propagate it into the implementations of the patterns

@madeline-k
Copy link
Contributor

Closing as this is superseded by #18663

@madeline-k madeline-k closed this Feb 1, 2022
mergify bot pushed a commit that referenced this pull request Jun 13, 2022
Fixes #15769, #15197
Supersedes #15497 by implementing the change for all patterns.
This PR implements support for ECS Exec in all ecs-patterns services.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
daschaa pushed a commit to daschaa/aws-cdk that referenced this pull request Jul 9, 2022
Fixes aws#15769, aws#15197
Supersedes aws#15497 by implementing the change for all patterns.
This PR implements support for ECS Exec in all ecs-patterns services.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@mzizzi mzizzi deleted the fargate-enable-execute-command branch November 24, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-ecs-patterns): Add enableExecuteCommand configuration property ApplicationLoadBalancedFargateService