-
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
Enable adding custom user data to ECS cluster #1711
Comments
Related: #623 |
Sooo... UserData can contain multiple files in a MIME multipart block? Would generating the same files in the regular userdata as side effect of running the shell script work? Would generating the same files using CfnInit work? Adding support for the latter one seems like a better use of time. |
CfnInit seems like it'd work -- I was coming at it from the point of view of a customer looking at the example custom user data on the docs and copy-pasting to seems like the most reasonable method on ASG. What do you suggest? |
Feels like this use case is better served by cfn-init et al. |
@rix0rrr cfn-init is arguably the way to go, but CDK will need a mechanism to add metadata in the AWS::CloudFormation::Init namespace to a resource such as a Launch Configuration or Launch Template. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html for details. |
Related: #777 |
I'm having the same issue as @SoManyHs in that I need to pass in a multipart mime document (and even base64 encoded gzipped userdata). cfn-init isn't functional enough for some of the use cases I am working with. It isn't yet clear to me if there is some way to work around this when synthesising. |
Looking at the quantity of I can open another issue if this is outside the scope of this one. |
@rix0rrr Cloud-Init offers declarative capabilities / stages such as at instance instantiation, at boot, per instance (picked up from AMI), once, etc. Also provides some measure of OS and Cloud independence which some customers want. e.g. common security hardening policies. That said in this instance I did refactor all the cloud-init into cfn-init bash with some packaging python code embedded in CDK - fetching logic, base64 encoding and decoding etc… as needed. CDK has simplified the environment build a lot and the team is enjoying it - even if most have to utilised it on Windows 10… |
I'd be interested in managing those within CDK... Currently we populate e.g.
|
This would possibly affect the implementation of custom attributes on instances: #1772 |
Is there a workaround here? I'm trying Cluster ec2Cluster = Cluster.Builder.create(this, "EC2Cluster").
vpc(vpc).
build();
ec2Cluster.getAutoscalingGroup().addUserData("echo \"$PARAM\""); but getting an NPE because |
@namedgraph Where did you find the |
But there is no get method, only a property autoScalingGroup, why you are getting null |
@kristianmandrup, If you use method addCapacity to add a capacity (instead of props), then the result value is an autoscaling group (cluster can be associated with multiple ASG) and you can use it to operate on user data. As a side note, there's new set of changes enabling capacity providers, AFIK. |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Currently, adding additional user data to an Autoscaling group and adding it to an ECS cluster is not a smooth experience.
The implementation of
autoscalinggroup.addUserData()
does not correctly process MIME multitype archives. E.g.:Results in the following CFN for LaunchConfiguration:
When deployed, the User Data on the ec2 instance looks like this:
It should look like this:
The above was generated using the ECS-cli with custom user data flag:
ecs-cli up --extra-user-data custom-user-data.txt --cluster blargh --capability-iam
Though the ECS CLI is able to leverage some go libraries for MIME multipart archive constructing/unpacking.
It would nice to have a smoother API around adding custom user data -- not sure if that's better served through an integration with a higher-level ECS construct or modifying the existing API in the Autoscaling library.
The text was updated successfully, but these errors were encountered: