-
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_autoscaling: ssm_session_permissions attribute of AutoScalingGroup() has no effect #25904
Comments
We add a managed policy to the Role if this is enabled, and we describe in the docstring that more configuration may be necessary. aws-cdk/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts Lines 1298 to 1300 in 0fd7f2b
You may see no difference in synth enabling this prop or not if you've imported your role, or set it to be immutable. |
i define the role with S3 access permissions for EC2 instances running in ASG in If I do not provide my custom role in ec2.LaunchTemplate() (since it optional according to the docs), I get the ecs_cluster.add_asg_capacity_provider(capacity_provider) where the |
It will take action on the role passed in as a prop to Please post your full snippet, it matters how you are defining |
the role is defined as follows (full snippet). It also worth mentioning here that if I add read_from_bucket_policy = {
"ReadFromEncryptedS3Bucket": iam.PolicyDocument(
statements=[
iam.PolicyStatement(
effect=iam.Effect.ALLOW,
resources=[stage_params.kms_key_arn],
actions=[
"kms:Decrypt",
"kms:GenerateDataKey",
],
),
]
)
}
asg_role = iam.Role(
self,
f"{config.ID}-asg-role",
assumed_by=iam.ServicePrincipal("ec2.amazonaws.com"),
managed_policies=[
iam.ManagedPolicy.from_aws_managed_policy_name("AmazonS3FullAccess"),
iam.ManagedPolicy.from_aws_managed_policy_name(
"EC2InstanceProfileForImageBuilderECRContainerBuilds"
),
],
inline_policies=read_from_bucket_policy,
role_name=f"{config.ID}-asg-role",
) it then is passed to the launch template launch_template = ec2.LaunchTemplate(
self,
f"{config.ID}-launch-template",
# lines omitted
role=asg_role,
security_group=sg_asg_ecs_import,
user_data=user_data,
) the launch template to ASG (where I tried to implement the discovered asg = autoscaling.AutoScalingGroup(
self,
f"{config.ID}-asg",
vpc=vpc,
mixed_instances_policy=autoscaling.MixedInstancesPolicy(
launch_template=launch_template,
# many lines omitted
)
auto_scaling_group_name=f"{config.ID}-asg",
min_capacity=config.MIN_EC2,
desired_capacity=config.DES_EC2,
max_capacity=config.MAX_EC2,
# further lines omitted
) and ASG to ESC capacity_provider = ecs.AsgCapacityProvider(
self,
f"{config.ID}-capacity-provider",
# lines omitted
auto_scaling_group=asg,
)
ecs_cluster.add_asg_capacity_provider(capacity_provider) |
You need to pass the role in to the ASG as well if you want to enable ssmSessionPermissions |
done. with following message
|
Ahh I see, the block of code I referenced above aws-cdk/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts Lines 1298 to 1300 in 0fd7f2b
only comes into effect when specifying a machine image and instance types. I think this line of code could move to just outside the else block it currently resides in, such that the |
great, thanks. looking forward to activate this feature. if you need further info or some tests, let me know. |
Previous PR was closed over 2 months ago, and there has been no activity after that. So I submitted the new PR. |
…o role specified in launch template (#27220) When we set ssmSessionPermissions to true, CDK adds `AmazonSSMManagedInstanceCore` managed policy to role specified in AutoScalingGroup construct. However, if the role specified in not AutoScalingGroup construct's prop but launch template, ssmSessionPermissions has no effect. This PR solves the issue by adding the managed policy even when role is specified in launch template. Closes #25904 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the bug
i have discovered the option ssm_session_permission in aws_autoscaling.AutoScalingGroup(), which can be set to True or False (default False) to update the instance profile accordingly to be able to connect to the instance via Session Manager, but the setting has no effect whatsoever.
Expected Behavior
Setting the ssm_session_permissions=True adds new SSM permissions to IAM instance profile so the instance can be managed by Systems Manager
Current Behavior
Setting the ssm_session_permissions=True or False has no effect
Reproduction Steps
Set Setting the ssm_session_permissions=True and run cdk diff in a command line or deploy the setting
of autoscaling group
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.83.0
Framework Version
No response
Node.js Version
18
OS
Ubuntu 20.04.5 LTS
Language
Python
Language Version
3.10.6
Other information
No response
The text was updated successfully, but these errors were encountered: