-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(aws-ecs-patterns): ECS Exec Support #15197
Comments
FYI, I found a workaround using Escape Hatches https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html My workaround is (Python) :
|
@xavierbuspatrol Did you create other resources manually such as the IAM policy for |
@danwiltshire I've got this, it's C# but hopefully will help: private static void EnableECSExec(ApplicationLoadBalancedFargateService service)
{
((IConstruct) service.Service).Node.Children.OfType<CfnService>().First().EnableExecuteCommand = true;
Permissions.ForRole(service.TaskDefinition.TaskRole)
.GrantForAllResource("ssmmessages:CreateControlChannel")
.GrantForAllResource("ssmmessages:CreateDataChannel")
.GrantForAllResource("ssmmessages:OpenControlChannel")
.GrantForAllResource("ssmmessages:OpenDataChannel");
}
private void EnableECSExecLogging(ApplicationLoadBalancedFargateService service)
{
var execLogs = new LogGroup(this, "ECSExecLogs", new LogGroupProps
{
LogGroupName = "ECS-Execute-Logs",
Retention = RetentionDays.TWO_YEARS
});
service.Cluster.Node.Children.OfType<CfnCluster>().First().Configuration = new CfnCluster.ClusterConfigurationProperty
{
ExecuteCommandConfiguration = new CfnCluster.ExecuteCommandConfigurationProperty
{
Logging = "OVERRIDE",
LogConfiguration = new CfnCluster.ExecuteCommandLogConfigurationProperty
{
CloudWatchLogGroupName = execLogs.LogGroupName
}
}
};
Permissions.ForRole(service.TaskDefinition.TaskRole)
.GrantForAllResource("logs:DescribeLogGroups")
.Grant("logs:CreateLogStream", execLogs.LogGroupArn)
.Grant("logs:DescribeLogStreams", execLogs.LogGroupArn)
.Grant("logs:PutLogEvents", execLogs.LogGroupArn);
} |
Working on this one in #15497 Apologies for not giving a heads up ahead of time. I found this issue after working on a patch. |
Here's how I handled this in typescript, maybe it's helpful for others. I added the AWS managed police for const ecsDeployment = new ecs_patterns.ApplicationLoadBalancedFargateService(this, 'EcsPattern', {
....
});
// Add need policy for EnabledExecuteCommand
ecsDeployment.taskDefinition.taskRole.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore'))
// Use escape hatch to add EnabledExecuteCommand to cf template
const cfnService = ecsDeployment.service.node.defaultChild as ecs.CfnService;
cfnService.addPropertyOverride('EnableExecuteCommand', true)
|
You can do "cfnService.enableExecuteCommand = true;" instead of addPropertyOverride since CloudFormation already supports the feature. This gives more type safety. |
I tried this with b0rked code:
What I ended up having to do was find the
|
Closed by #18663. |
|
Add ECS Exec Support to the higher level constructs in ecs-patterns
Use Case
As a user, I want to set the flag
enableExecuteCommand: true
in myaws-ecs-patterns.ApplicationLoadBalancedFargateService
construct.Proposed Solution
This is currently possible with the
ecs
module but not theecs-patterns
(see https://docs.aws.amazon.com/cdk/api/latest/docs/aws-ecs-readme.html#ecs-exec-command)Relevant PRs: #13618
#14670
Solution would be to enable this flag in the higher level ecs-patterns constructs as well.
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: