question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subnet CIDR as security group rule source

See original GitHub issue

How can you get the CIDR for a subnet created by the same stack and add it to a security group rule?

    const vpc = new ec2.VpcNetwork(this, 'VPC', {
      subnetConfiguration: [
        {
          cidrMask: 28,
          subnetType: SubnetType.Public,
        },
        {
          cidrMask: 24,
          subnetType: SubnetType.Private,
        }
      ],
    });

  // Something similar to this?
  publicSecurityGroup.connections.allowFrom(vpc.publicSubnets[0].cidr, new ec2.TcpPort(443), 'HTTPS ingress from private SG to public SG');

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:22
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
karthikns16commented, Aug 21, 2020

I am in same state as this. I have a VPC which is created with subnets (public and private) in 2 AZ’s. I want the CIDR block of the subnet which I was trying to get using this simple logic for subnet in self.vpc.isolated_subnets: subnet.cidrblock

only to find out the .cidrblock is not a property that is exposed.

0reactions
github-actions[bot]commented, Mar 8, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Control traffic to resources using security groups
Use security groups to control the inbound and outbound traffic for associated resources.
Read more >
Security group rules - Amazon Elastic Compute Cloud
The rules of a security group control the inbound traffic that's allowed to reach the instances that are associated with the security group....
Read more >
AWS Security Group: Best Practices & Instructions - CoreStack
Learn the most important AWS Security Group best practices and follow ... outbound rules, then set the source and destination as the security...
Read more >
AWS EC2 with public subnets with open ports - nOps
For instances provisioned in Public subnets, you must ensure that no inbound rules exist in any security group that allows unrestricted access (i.e., ......
Read more >
Configuring security groups and ACLs for use with a VPN server
If you configure security groups and ACLs on the VPN server's subnet, ... which CIDR should be specified when you create the security...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found