aws / aws/aws-cdk

(cli) cdk import gives "unsupported resource type" errors for resource types which should be supported

Open
#28,715 14 comments 2 reactions 0 assignees View on GitHub
bug cli effort/medium p2 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I am trying to import pre-created resources into my stack via `cdk import` cli

[The docs](https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-import) say:

> See the [list of resources that can be imported here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html)

...and that page has a table of importable resource types (which seems pretty comprehensive)

But when I try to import the resources I get errors like "unsupported resource type ___, skipping import" ...for resource types which are found in the importable list linked in the docs

### Expected Behavior

the resources are imported, or I get an error explaining why not

### Current Behavior

I get these errors:
```
my-stack/Web Lambda/Invoke2UTWxhlfyqbT5FTn--5jvgbLgj+FfJwzswGk55DU1H--Y=: unsupported resource type AWS::Lambda::Permission, skipping import.
my-stack/ALB/Resource: unsupported resource type AWS::ElasticLoadBalancingV2::LoadBalancer, skipping import.
my-stack/ALB/SecurityGroup/Resource: unsupported resource type AWS::EC2::SecurityGroup, skipping import.
my-stack/ALB/ALB-http-listener/Resource: unsupported resource type AWS::ElasticLoadBalancingV2::Listener, skipping import.
my-stack/ALB/ALB-http-listener/ALB-targetsGroup/Resource: unsupported resource type AWS::ElasticLoadBalancingV2::TargetGroup, skipping import.
No resources selected for import.
```

so there are five resources identified for import, of the following types:
- `AWS::Lambda::Permission`
- `AWS::ElasticLoadBalancingV2::LoadBalancer`
- `AWS::EC2::SecurityGroup`
- `AWS::ElasticLoadBalancingV2::Listener`
- `AWS::ElasticLoadBalancingV2::TargetGroup`

all of these resource types are found in the table of importable resource types linked in the docs

### Reproduction Steps

at the moment I am unable to provide a minimal repro

but basically:

- create a cdk stack with a Lambda function (mine also has other stuff - S3 bucket, RDS db etc, but doesn't seem relevant)
- via the AWS web console add an Application Load Balancer with the Lambda as a target
- write code in the cdk stack to mimic the manually created ALB
- run `cdk import` cli

### Possible Solution

I am guessing that maybe, rather than the docs being totally wrong, my resources are non-importable for some other reason and the error message is wrong, obscuring the real problem?

### Additional Information/Context

_No response_

### CDK CLI Version

2.121.1 (build d86bb1a)

### Framework Version

_No response_

### Node.js Version

v18.18.0

### OS

macOS 14.1

### Language

Python

### Language Version

3.11.5

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the cdk import CLI flow and trace how CloudFormation resource types are checked against the importable-resource list. Reproduce the reported unsupported-resource messages if possible, then compare the CLI's supported types and error handling with the AWS documentation. Done means supported resources are imported or the CLI reports the actual reason they cannot be imported.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cli, 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.