aws / aws/aws-cdk

aws-servicecatalog: VPC product created with L2 ec2.Vpc not generating subnets

Open
#34,588 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

VPC product created with L2 `aws-ec2.Vpc` construct with subnet configuration supplied in a `aws-servicecatalog.ProductStack` class ignores the subnet configuration supplied when generating the template.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

_No response_

### Expected Behavior

All configuration options supplied to the `aws-ec2.Vpc` construct should be adhered to when the product cloudformation template is synthesized

### Current Behavior

Subnet configuration is ignored and no subnets are created in the synthesized template

### Reproduction Steps

````python
from aws_cdk import (
Stack,
aws_servicecatalog as servicecatalog,
aws_ec2 as ec2,
aws_iam as iam,
CfnParameter,
)
from constructs import Construct

class VpcServiceCatalogPortfolioStack(Stack):

def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

vpc_portfolio = servicecatalog.Portfolio(self, "VPC_Portfolio",
display_name="VPC Portfolio",
provider_name="Engineering Team",
description="Pre-configured VPCs available for various use cases including connectivity to the internet and other tenants.",
)

isolated_vpc_stack_history = servicecatalog.ProductStackHistory(self, "IsolatedVpcStackHistory",
product_stack=IsolatedVpc(self, "Isolated_VPC"),
current_version_name="v1",
current_version_locked=False,
)

isolated_vpc_product = servicecatalog.CloudFormationProduct(self, "IsolatedVpcProduct",
product_name="Isolated/Sandbox VPC",
owner="Engineering",
product_versions=[
isolated_vpc_stack_history.current_version()
]
)

vpc_portfolio.add_product(isolated_vpc_product)

launch_role = iam.Role.from_role_name(self, "LaunchRole",
role_name="RES-ServiceCatalog-VPC-Launch")

vpc_portfolio.set_local_launch_role(isolated_vpc_product, launch_role)

class IsolatedVpc(servicecatalog.ProductStack):
def __init__(self, scope, id):
super().__init__(scope, id)

availability_zone_param = CfnParameter(self, "AvailabilityZoneNumber",
description="The number of availability zones that this VPC should span",
type="Number",
min_value=1,
max_value=3,
)


vpc = ec2.Vpc(self, "VPC",
ip_addresses=ec2.IpAddresses.cidr("10.254.0.0/22"),
max_azs=availability_zone_param.value_as_number,
subnet_configuration=[
ec2.SubnetConfiguration(
cidr_mask=24,
name='private',
subnet_type=ec2.SubnetType.PRIVATE_ISOLATED
),
ec2.SubnetConfiguration(
cidr_mask=24,
name='public',
subnet_type=ec2.SubnetType.PUBLIC
)],
enable_dns_support=True,
enable_dns_hostnames=True,
restrict_default_security_group=False,
create_internet_gateway=True,
vpn_gateway=False
)
````

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS CDK Library version (aws-cdk-lib)

2.199.0

### AWS CDK CLI version

2.1007.0

### Node.js Version

22.15.0

### OS

Windows 11

### Language

Python

### Language Version

3.12.3

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the IsolatedVpc servicecatalog.ProductStack reproduction using aws-cdk-lib 2.199.0, then synthesize the CloudFormation product template and inspect how the ec2.Vpc subnet_configuration is handled. Done means the synthesized template includes the requested private and public subnets and respects the supplied availability-zone configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
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.