Skip to content

docs(ecs): add an example for AsgCapacityProvider with EC2 LaunchTemplate#21047

Merged
mergify[bot] merged 3 commits intoaws:mainfrom
kimisme9386:main
Jul 8, 2022
Merged

docs(ecs): add an example for AsgCapacityProvider with EC2 LaunchTemplate#21047
mergify[bot] merged 3 commits intoaws:mainfrom
kimisme9386:main

Conversation

@kimisme9386
Copy link
Copy Markdown
Contributor

This pull request offer an example to resolve #20870 for AutoScalingGroup uses EC2 LaunchTemplate within ecs cluster.

Closes #20870

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jul 8, 2022

@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Jul 8, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team July 8, 2022 00:16
pahud
pahud previously requested changes Jul 8, 2022
@pahud pahud changed the title fix(ecs): add example for AutoScalingGroup uses EC2 LaunchTemplate chore(ecs): add an example for AsgCapacityProvider with EC2 LaunchTemplate Jul 8, 2022
Co-authored-by: Pahud Hsieh <pahudnet@gmail.com>
@mergify mergify bot dismissed pahud’s stale review July 8, 2022 01:02

Pull request has been modified.

@pahud
Copy link
Copy Markdown
Contributor

pahud commented Jul 8, 2022

LGTM 🚢

@TheRealAmazonKendra TheRealAmazonKendra changed the title chore(ecs): add an example for AsgCapacityProvider with EC2 LaunchTemplate docs(ecs): add an example for AsgCapacityProvider with EC2 LaunchTemplate Jul 8, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 8, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: ae972ae
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 95103b4 into aws:main Jul 8, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 8, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

daschaa pushed a commit to daschaa/aws-cdk that referenced this pull request Jul 9, 2022
…late (aws#21047)

This pull request offer an example to resolve aws#20870 for AutoScalingGroup uses EC2 LaunchTemplate within ecs cluster. 

Closes aws#20870
@rajialtooro
Copy link
Copy Markdown

The example threw errors on my end when I tried to deploy it, I used version 2.111.x then downgraded to the used version 2.22.0 and still got the same error
The provided launch template does not expose or does not define its role.
I created a 1:1 copy of the example

this.cluster = new cdk.aws_ecs.Cluster(this, "Cluster", {
  vpc: this.vpc,
});
const launchTemplate = new cdk.aws_ec2.LaunchTemplate(this, "ASG-LT", {
  instanceType: new cdk.aws_ec2.InstanceType("t3.large"),
  machineImage: cdk.aws_ecs.EcsOptimizedImage.amazonLinux2(),
  userData: cdk.aws_ec2.UserData.forLinux(),
});

this.asg = new cdk.aws_autoscaling.AutoScalingGroup(this, "ASG", {
  vpc: this.vpc,
  mixedInstancesPolicy: {
    instancesDistribution: {
      onDemandPercentageAboveBaseCapacity: 50,
    },
    launchTemplate,
  },
});

this.cluster.addAsgCapacityProvider(
  new cdk.aws_ecs.AsgCapacityProvider(this, "AsgCP", {
    autoScalingGroup: this.asg,
    machineImageType: cdk.aws_ecs.MachineImageType.AMAZON_LINUX_2,
  })
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EC2: LaunchTemplate does not create a UserData when machineImage is provided used with AsgCapacityProvider

5 participants