- Newest
- Most votes
- Most comments
This is a simple example from the @aws-cdk/aws-ec2
core library.
this.instance.addUserData('yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm');
It uses the addUserData
method on the ec2.Instance class. You just pass it a list of commands and it adds the commands to the user data script. https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.Instance.html#add-wbr-user-wbr-datacommands
A more complicated example can be seen in the @aws-cdk/aws-eks
core library. There is a renderUserData
function that creates a list of commands to add to the user data.
-
function used: https://github.com/aws/aws-cdk/blob/22fe0ce5d5c39564c85f2a4af6f150bd8fac1bae/packages/%40aws-cdk/aws-eks/lib/cluster.ts#L511
-
test showing it rendered in CloudFormation: https://github.com/aws/aws-cdk/blob/22fe0ce5d5c39564c85f2a4af6f150bd8fac1bae/packages/%40aws-cdk/aws-eks/test/integ.eks-cluster.defaults.expected.json#L1069
Relevant content
- asked 2 years ago
- asked 5 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 years ago