hello, looking for some samples of using an ASG on...
# getting-started
m
hello, looking for some samples of using an ASG on AWS with a load balancer (I'm using TS) is there an example I can look at?
b
which type of load balancer? are you using fargate or just ec2 instances?
m
ec2 instances
b
and which language SDK?
m
typescript, but any language example is ok
I'm making slow progress so far, this is essentially what i have. next step is to create an ASG and LB - with the user data script
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as fs from 'fs';

// Allocate a new VPC with the default settings:
const vpc = new awsx.ec2.Vpc("ci-cd", {
    // runners will be available in multiple zones
    numberOfAvailabilityZones: 2,
    // this is the smallest cidr block that we can use - 64 IPs
    // split across 4 subnets - 16 per subnet, minimum enforced by aws
    cidrBlock: "10.0.0.0/26"
});

// Export a few resulting fields to make them easy to use:
export const vpcId: pulumi.Output<string> = vpc.id;
export const vpcPrivateSubnetIds: Promise<pulumi.Output<string>[]> = vpc.privateSubnetIds;
export const vpcPublicSubnetIds: Promise<pulumi.Output<string>[]> = vpc.publicSubnetIds;

// create a security group allowing inbound http(s) / ssh  traffic, all outbound traffic
const group = new aws.ec2.SecurityGroup("allow-http-ssh", {
    ingress: [
        { protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 443, toPort: 443, cidrBlocks: ["0.0.0.0/0"] },
    ],
    egress: [
        { protocol: "-1", fromPort: 0, toPort: 0, cidrBlocks: ["0.0.0.0/0"] },
    ],
});

// create an ec2 instance in each private subnet for github runner
const userData = fs.readFileSync('./user_data.sh','utf8');
b
gives me a few minutes, I have something sort of done here
m
ok ty
b
m
ty, taking a look
looks great I'll try it - I'm guessing
instanceSecurityGroups
needs to be specified somewhere in the CF template. It's not used right now
b
it goes in the launch template, I'll try figure out what I missed there
@many-yak-61188 refresh the page, pushed a fix
m
👍