0.2.1 • Published 2 years ago

@stackspot/cdk-vpc v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

vpc-env-jsii-component

aws-cdk jsii npm-version nuget-version npm-downloads nuget-downloads license

Component to create a VPC.

How to use

Below are all languages supported by the AWS CDK.

C

Install the dependency:

dotnet add package StackSpot.Cdk.Vpc

Import the construct into your project, for example:

using Amazon.CDK;
using Constructs;
using StackSpot.Cdk.Vpc;

namespace MyStack
{
    public class MyStack : Stack
    {
        internal MyStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            Vpc vpc = new Vpc(this, "MyVpc", new VpcProps {
                VpcName = "MyVpc"
            });
        }
    }
}

F

Not yet supported.

Go

Not yet supported.

Java

Not yet supported.

JavaScript

Install the dependency:

npm install --save @stackspot/cdk-vpc

Import the construct into your project, for example:

const { Stack } = require('aws-cdk-lib');
const { Vpc } = require('@stackspot/cdk-vpc');

class MyStack extends Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const vpc = new Vpc(this, 'MyVpc', { vpcName: 'MyVpc' });
  }
}

module.exports = { MyStack };

Python

Not yet supported.

TypeScript

Install the dependency:

npm install --save @stackspot/cdk-vpc

Import the construct into your project, for example:

import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { Vpc } from '@stackspot/cdk-vpc';

export class MyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const vpc = new Vpc(this, 'MyVpc', { vpcName: 'MyVpc' });
  }
}

Construct Props

Using an existing VPC

NameTypeDescription
vpcDefaultbooleanWhether to match the default VPC.
vpcIdstringThe identifier of the VPC to be used.
vpcRegionstringOptional to override inferred region.
vpcNamestringThe VPC name.

Creating a VPC

NameTypeDescription
vpcCidrstringIf don't inform the vpcId, a VPC with this CIDR will be created. Default: 10.0.0.0/16.
vpcMaxAzsnumberDefine the maximum number of AZs to be used. Default: 99.
vpcNamestringThe VPC name.
vpcSubnetConfigurationSubnetConfiguration[]Specify configuration parameters for a single subnet group in a VPC.

Subnets

NameTypeDescription
subnetsAvailabilityZonesstring[]Select subnets only in the given AZs.
subnetsGroupNamestringSelect the subnet group with the given name.
subnetIdsstring[]The identifiers of the subnets to be used.
subnetsOnePerAzbooleanIf true, return at most one subnet per AZ.
subnetsTypeSubnetTypeType of subnet to be used. Default: SubnetType.PUBLIC

Another Props

ApiVpcEndpointCreateProps

NameTypeDescription
stackNamestringThe name of the Stack
securityGroupIdstringThe identifier of the security id to be used on VPC Endpoint. (Optional)
subnetTypeSubnetTypeThe type of subnet to use.
portnumberThe port to be used by service linked to VPC Endpoint
vpcIVpcThe VPC to use.

Properties

NameTypeDescription
subnetsSubnetSelectionSubnets used on the VPC.
virtualPrivateCloudIVpcVPC to be used.

Methods

NameDescription
static createApiVpcEndpoint(scope, props)Create a VPC Endpoint.

createApiVpcEndpoint(scope, vpc, props)

public static createApiVpcEndpoint(scope: Construct,vpc: IVpc,props: ApiVpcEndpointCreateProps)

Parameters

Create a VPC Endpoint from an existing VPC.

IAM Least privilege

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:AllocateAddress",
        "ec2:AssociateRouteTable",
        "ec2:AttachInternetGateway",
        "ec2:CreateInternetGateway",
        "ec2:CreateNatGateway",
        "ec2:CreateRoute",
        "ec2:CreateRouteTable",
        "ec2:CreateSubnet",
        "ec2:CreateTags",
        "ec2:CreateVpc",
        "ec2:DeleteInternetGateway",
        "ec2:DeleteNatGateway",
        "ec2:DeleteRoute",
        "ec2:DeleteRouteTable",
        "ec2:DeleteSubnet",
        "ec2:DeleteTags",
        "ec2:DeleteVpc",
        "ec2:DescribeAddresses",
        "ec2:DescribeAvailabilityZones",
        "ec2:DescribeInternetGateways",
        "ec2:DescribeNatGateways",
        "ec2:DescribeRouteTables",
        "ec2:DescribeSubnets",
        "ec2:DescribeVpcs",
        "ec2:DetachInternetGateway",
        "ec2:DisassociateRouteTable",
        "ec2:ModifySubnetAttribute",
        "ec2:ModifyVpcAttribute",
        "ec2:ReleaseAddress",
        "ec2:ReplaceRoute",
        "ssm:GetParameters"
      ],
      "Resource": "*"
    }
  ]
}

Development

Prerequisites

Setup

cd vpc-jsii-component
npm install
0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago