-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(cli) cdk import gives "unsupported resource type" errors for resource types which should be supported #28715
Comments
Can you share your code snippets and full CLI command for the two steps? |
the code I've added looks like: load_balancer = elb.ApplicationLoadBalancer(
self,
"ALB",
vpc=vpc,
vpc_subnets=ec2.SubnetSelection(
subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS,
),
internet_facing=False,
)
load_balancer.connections.allow_from(
other=ec2.Peer.ipv4(gateway_cidr),
port_range=ec2.Port.all_icmp(),
)
load_balancer.connections.allow_from(
other=ec2.Peer.ipv4(gateway_cidr),
port_range=ec2.Port.tcp(80),
)
alb_listener = load_balancer.add_listener(
"ALB-http-listener",
port=80,
open=True,
)
alb_listener.add_targets(
"ALB-targets",
targets=[
elb_targets.LambdaTarget(
cast(lambda_.IFunction, django_lambdas.web_lambda)
),
],
) and then I do like |
I'm getting a similar error with a following message: "unsupported resource type AWS::ApiGateway::BasePathMapping, skipping import." Also running
EDIT: |
@qrsor part of that sounds like a different issue I have a result from but I now have cdk am wishing I had used Terraform instead at this point would love if there was any kind of workaround, besides what I currently have which is just comment out these items from the stack and carry on with the manually deployed resources e.g. now I want to deploy the stack in a new env, so I have to conditionally define those resources in the stack so they can at least be cdk deployed for one of the envs, but not for the other ... it's just a frustrating mess |
@anentropic make sure you have explicitly set DeletionPolicy on imported resources. Without it the resources will not be recognized. |
thanks... is this documented somewhere? which deletion policy do they need to have? |
the primary resource I am trying to import is an the closest thing to a deletion policy arg I can see on that is a |
ah I see, it's a method, not all resources have it as an arg like S3 Bucket does adding |
Could you maybe test the DESTROY Removal policy? Not in PROD but some test environment? |
the code for the chunk I'm trying to import looks like: from aws_cdk import (
aws_elasticloadbalancingv2 as elb,
aws_elasticloadbalancingv2_targets as elb_targets,
aws_lambda as lambda_,
)
load_balancer = elb.ApplicationLoadBalancer(
self,
"ALB",
load_balancer_name=resource_name_template.format("analytics-dev-alb"),
vpc=vpc,
vpc_subnets=ec2.SubnetSelection(
subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS,
),
internet_facing=False,
)
load_balancer.apply_removal_policy(RemovalPolicy.DESTROY)
if config.gateway_cidr:
gateway_peer = ec2.Peer.ipv4(config.gateway_cidr)
else:
gateway_peer = ec2.Peer.any_ipv4()
load_balancer.connections.allow_from(
other=gateway_peer,
port_range=ec2.Port.all_icmp(),
)
load_balancer.connections.allow_from(
other=gateway_peer,
port_range=ec2.Port.tcp(80),
)
# load_balancer.log_access_logs(logs_bucket, prefix="alb")
alb_listener = load_balancer.add_listener(
"ALB-http-listener",
port=80,
open=True,
)
alb_listener.add_targets(
"ALB-targets",
targets=[
elb_targets.LambdaTarget(
cast(lambda_.IFunction, django_lambdas.web_lambda)
),
],
)
alb_listener.apply_removal_policy(RemovalPolicy.DESTROY) same errors with |
What does |
the ALB was created manually
as per my original post, all of the resource types it complains "unsupported resource type" for are listed in the table on that page as supporting import |
|
I would suggest two possible actions:
|
Describe the bug
I am trying to import pre-created resources into my stack via
cdk import
cliThe docs say:
...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:
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:
cdk import
cliPossible 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
The text was updated successfully, but these errors were encountered: