Skip to content
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

Creating an ASG with public subnets fails. #3410

Closed
2 of 5 tasks
vaneek opened this issue Jul 24, 2019 · 4 comments
Closed
2 of 5 tasks

Creating an ASG with public subnets fails. #3410

vaneek opened this issue Jul 24, 2019 · 4 comments
Assignees
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made.

Comments

@vaneek
Copy link

vaneek commented Jul 24, 2019

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce

  1. Creating an ASG using an imported VPC with only public subnets fails with the following error message,
jsii.errors.JSIIError: There are no 'Private' subnets in this VPC. Use a different VPC subnet selection.

Code to create stack,

class ASGStack(core.Stack):

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

        vpc = ec2.Vpc.from_lookup(self, "VPC", is_default=True)
        
        asg = autoscaling.AutoScalingGroup(
            self, "ASG",
            vpc=vpc,
            vpc_subnets=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC, one_per_az=True),
            instance_type=ec2.InstanceType.of(
                ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.LARGE
            ),
            machine_image=ec2.GenericLinuxImage({
                'eu-west-2': 'ami-1234,
                'eu-west-1': 'ami-5678,
            }),
        )
  1. Using a VPC created by the same stack ASG construct only uses PRIVATE subnets even when explicitly selecting PUBLIC subnets.
class ASGStack(core.Stack):

    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)
        
        vpc = ec2.Vpc(self, "VPC")
        
        asg = autoscaling.AutoScalingGroup(
            self, "ASG",
            vpc=vpc,
            vpc_subnets=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC, one_per_az=True),
            instance_type=ec2.InstanceType.of(
                ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.LARGE
            ),
            machine_image=ec2.GenericLinuxImage({
                'eu-west-2': 'ami-1234,
                'eu-west-1': 'ami-5678,
            }),
        )

Snippet from generated cloudformation template,

        "VPCZoneIdentifier": [
          {
            "Ref": "VPCPrivateSubnet1Subnet8BCA10E0"
          },
          {
            "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A"
          },
          {
            "Ref": "VPCPrivateSubnet3Subnet3EDCD457"
          }
        ]
  • What is the expected behavior (or behavior of feature suggested)?
    Subnet placement to use selected subnets.

  • What is the motivation / use case for changing the behavior or adding this feature?

  • Please tell us about your environment:

ℹ️ CDK Version: 1.1.0 (build 1a11e96)
ℹ️ AWS environment variables:

  • AWS_CLOUDWATCH_HOME = /opt/aws/apitools/mon
  • AWS_PATH = /opt/aws
  • AWS_AUTO_SCALING_HOME = /opt/aws/apitools/as
  • AWS_ELB_HOME = /opt/aws/apitools/elb
    ℹ️ No CDK environment variables
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
@vaneek vaneek added the needs-triage This issue or PR still needs to be triaged. label Jul 24, 2019
@vaneek
Copy link
Author

vaneek commented Jul 26, 2019

Explicitely tagging a subnet in an imported VPC with aws-cdk:subnet-type as Public also does not work as in example 1. Falsely tagging as Private and using default subnet selection succeeds. It appears the logic has gotten off tracks somewhere as it is only possible to create an ASG with Private subnets.

@eladb eladb added the @aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling label Aug 13, 2019
@eladb eladb assigned eladb and rix0rrr and unassigned eladb Aug 13, 2019
@rix0rrr rix0rrr added bug This issue is a bug. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 28, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Sep 16, 2019

Can you check whether this has gotten fixed by #3784 ?

@NGL321 NGL321 added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed status/needs-response labels Sep 16, 2019
@NGL321 NGL321 added closing-soon This issue will automatically close in 4 days unless further comments are made. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Oct 16, 2019
@SomayaB
Copy link
Contributor

SomayaB commented Oct 22, 2019

Can you check whether this has gotten fixed by #3784 ?

@vaneek

@rix0rrr
Copy link
Contributor

rix0rrr commented Oct 24, 2019

If not there it will be fixed by #4668. Closing.

@rix0rrr rix0rrr closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made.
Projects
None yet
Development

No branches or pull requests

5 participants