CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pulumi--aws

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

vpc.mddocs/networking/

VPC - Virtual Private Cloud

Amazon VPC lets you provision a logically isolated section of AWS Cloud. VPC resources are part of the ec2 module.

Common Tasks

Create a basic VPC with public and private subnets

const vpc = new aws.ec2.Vpc("main", { cidrBlock: "10.0.0.0/16" });
const publicSubnet = new aws.ec2.Subnet("public", {
    vpcId: vpc.id,
    cidrBlock: "10.0.1.0/24",
});

Set up NAT Gateway for private subnet internet access

const eip = new aws.ec2.Eip("nat", { domain: "vpc" });
const natGw = new aws.ec2.NatGateway("main", {
    allocationId: eip.id,
    subnetId: publicSubnet.id,
});

Configure VPC peering between two VPCs

const peering = new aws.ec2.VpcPeeringConnection("peer", {
    vpcId: vpcA.id,
    peerVpcId: vpcB.id,
    autoAccept: true,
});

Core Resources

VPC networking resources are available through aws.ec2:

import { ec2 } from "@pulumi/aws";

Key Resources

  • Vpc - Virtual Private Cloud
  • Subnet - Subnet within VPC
  • InternetGateway - Internet connectivity
  • NatGateway - NAT for private subnets
  • RouteTable - Routing configuration
  • SecurityGroup - Firewall rules
  • NetworkAcl - Network ACLs
  • VpcEndpoint - Private AWS service access
  • VpcPeeringConnection - VPC peering
  • FlowLog - VPC flow logs

See EC2 Documentation for detailed API signatures and examples.

Usage Example

import * as aws from "@pulumi/aws";

// Create VPC
const vpc = new aws.ec2.Vpc("main", {
    cidrBlock: "10.0.0.0/16",
    enableDnsHostnames: true,
    enableDnsSupport: true,
    tags: { Name: "main-vpc" },
});

// Create internet gateway
const igw = new aws.ec2.InternetGateway("main", {
    vpcId: vpc.id,
});

// Create public subnet
const publicSubnet = new aws.ec2.Subnet("public", {
    vpcId: vpc.id,
    cidrBlock: "10.0.1.0/24",
    mapPublicIpOnLaunch: true,
    availabilityZone: "us-west-2a",
});

// Create private subnet
const privateSubnet = new aws.ec2.Subnet("private", {
    vpcId: vpc.id,
    cidrBlock: "10.0.2.0/24",
    availabilityZone: "us-west-2a",
});

// Create NAT gateway
const eip = new aws.ec2.Eip("nat", { domain: "vpc" });
const natGw = new aws.ec2.NatGateway("main", {
    allocationId: eip.id,
    subnetId: publicSubnet.id,
});

// Public route table
const publicRt = new aws.ec2.RouteTable("public", {
    vpcId: vpc.id,
    routes: [{
        cidrBlock: "0.0.0.0/0",
        gatewayId: igw.id,
    }],
});

new aws.ec2.RouteTableAssociation("public", {
    subnetId: publicSubnet.id,
    routeTableId: publicRt.id,
});

// Private route table
const privateRt = new aws.ec2.RouteTable("private", {
    vpcId: vpc.id,
    routes: [{
        cidrBlock: "0.0.0.0/0",
        natGatewayId: natGw.id,
    }],
});

new aws.ec2.RouteTableAssociation("private", {
    subnetId: privateSubnet.id,
    routeTableId: privateRt.id,
});

export const vpcId = vpc.id;

Related Services

Install with Tessl CLI

npx tessl i tessl/npm-pulumi--aws

docs

index.md

quickstart.md

README.md

tile.json