aws / aws/aws-cdk

(ec2): import an existing AutoScalingGroup with a Role

Open
#13,756 12 comments 8 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 effort/small feature-request feature/enhancement p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

I'm trying to referring an existing AutoScalingGroup from my CodeDeploy with AutoScalingGroup.**from_auto_scaling_group_name** static method in order to integrate with CodePipeline for automating EC2/On-premise deployment. However, the Role from AutoScalingGroup is not being imported.

### Reproduction Steps

- Refer existing AutoScaling Group:
`asg_1 = autoscaling.AutoScalingGroup.from_auto_scaling_group_name(self, "AutoScaleGroup", "WSAutoscaleStack-webServerAsgIdASG12345-XXXXXX")`

- EC2 Deployment Groups:
`deployment_group = codedeploy.ServerDeploymentGroup(self, "CodeDeployDeploymentGroup", deployment_group_name="MyDeploymentGroup", install_agent=True, auto_scaling_groups=[asg_1])`

### What did you expect to happen?

Ideally, the referenced resource should be imported as an object, so that I can use it all dependents including iam.role from the resource. (c.f. from CodeDeploy Application Environment configuration, choose the Amazon EC2 Auto Scaling group where the current application revision is deployed)

### What actually happened?

The error that I'm getting is as follows:
`jsii.errors.JSIIError: Cannot get policy fragment of AMIPipelineStack/AutoScaleGroup, resource imported without a role`

### Environment

- **CDK CLI Version :** 1.94.0 (build 2c1c0eb)
- **Framework Version:**
- **Node.js Version:** v15.11.0
- **OS :** macOS Catalina
- **Language (Version):** Python (3.8.7)

### Other

This issue was posted and confirmed. The issue is linked,
https://stackoverflow.com/questions/66748035/refer-import-existing-autoscalinggroup-resource-from-cdk-stack

---

This is :bug: Bug Report

Contributor guide

Open the contributing guide

Research direction

Start with AutoScalingGroup.from_auto_scaling_group_name and the CodeDeploy ServerDeploymentGroup integration described in the reproduction. Trace how the imported AutoScalingGroup handles its role and compare that with the policy-fragment error; done means the existing group's role is available to dependents without the reported JSIIError.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.