-
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: Cloud-init script for EC2 fails when using AWS Linux 2023 #28518
Comments
Thank you for the |
Happy to help raise a PR to implement it if the possible solution is acceptable :) |
Also experiencing this. Need an option to specify |
@juinquok also happy to help with this. Additionally, we should add a note that if you choose |
Just to add: We've noticed this issue with AL2 as well. We solved it by installing iptables-services in the userdata, so that the command can be run. |
@pahud Should I raise a PR to implement this change if its agreeable with the team? |
@juinquok Yes feel free to submit a PR and let's move this forward. |
Comments on closed issues and PRs are hard for our team to see. |
1 similar comment
Comments on closed issues and PRs are hard for our team to see. |
…e=false` and also deprecate property (#32763) ### Issue # (if applicable) Closes #28518. ### Reason for this change When `canContainersAccessInstanceRole=false`, wrong commands are added to the ASG UserData, as described in the issue linked above. Reason for deprecating the `canContainersAccessInstanceRole` option is detailed in #32609. ### Description of changes - Added deprecation tag to all `canContainersAccessInstanceRole` options. - Created two feature flags to control the `canContainersAccessInstanceRole` behaviour - Added new commands if customer opted to use them via setting the right feature flags ### Describe any new or updated permissions being added None ### Description of how you validated changes A new integ test is added to ensure the commands in UserData executes without throwing errors. The existing integ tests are updated to have the default feature flag values and they are passing. This should prove that there will not be any change to existing CDK apps. Unit tests are added for each platform, combination of possible values for `canContainersAccessInstanceRole` + possible values for the feature flags (3 platforms * 3 possible values for `canContainersAccessInstanceRole` * 2 possible values for `@aws-cdk/aws-ecs:disableEcsImdsBlocking` * 2 possible values for `@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature` = 36 unit tests). ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
When using EC2 as the capacity provider in the
addAsgCapacityProvider
method, the user is expected to specify themachineImageType
for the capcity provider. In doing so, it will add a user data script that will inject additional data that is relevant to the user for the /etc/ecs/ecs.config fileOne of the commands that is injected is:
On AWS Linux 2023 running the Linux 6.1.66-91.160.amzn2023.x86_64 kernel, this command results in an error when executing the cloud-init file.
This results in the line after
to not get run which is not ideal.
Expected Behavior
It should successfully run the required ECS setup configs when the EC2 instance starts.
Current Behavior
The cloud-init script will fail with the error message
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, reload-or-restart, try-reload-or-restart, force-reload, status, condrestart). For other actions, please try to use systemctl.
Reproduction Steps
Start an ECS Cluster with an EC2 capacity provider and the AMI in the launch template for the autoscaling group to be the latest AWS Linux 2023 AMI (
ecs.EcsOptimizedImage.amazonLinux2023(AmiHardwareType.STANDARD)
). The error will occur when the instance starts up and the logs can be found in/var/log/cloud-init-output.log
Possible Solution
Introduce a new
machineImageType
in theaddAsgCapacityProvider
method and name itAMAZON_LINUX_2023
. In theconfigureAutoScalingGroup
method incluster.ts
, add in a new switch condition to render different user data for the ECS Optimized AMI for AWS Linux 2023. In particular, thesudo service iptables save
will be changed tosudo iptables-save > /etc/sysconfig/iptables
which will not throw the same error as above.Additional Information/Context
No response
CDK CLI Version
2.114.1 (build 02bbb1d)
Framework Version
No response
Node.js Version
v18.17.0
OS
macOS 14.2
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: