Skip to content

Commit

Permalink
chore: setup ice
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Oct 23, 2023
1 parent 00a3c5e commit e3e3324
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const subnet = new aws.ec2.Subnet('beet-bot-subnet', {
})

const igw = new aws.ec2.InternetGateway('beet-bot-igw', { vpcId: vpc.id })
const rt = new aws.ec2.RouteTable('beet-bot-rt', {
const rtb = new aws.ec2.RouteTable('beet-bot-rt', {
vpcId: vpc.id,
routes: [
{
Expand All @@ -47,17 +47,22 @@ const rt = new aws.ec2.RouteTable('beet-bot-rt', {
]
})

const rta = new aws.ec2.RouteTableAssociation('beet-bot-rta', {
routeTableId: rt.id,
const rtbAssoc = new aws.ec2.RouteTableAssociation('beet-bot-rta', {
routeTableId: rtb.id,
subnetId: subnet.id
})

// Allow SSH and HTTP
const group = new aws.ec2.SecurityGroup('beet-bot-security', {
// SSH security group
const ssh = new aws.ec2.SecurityGroup('beet-bot-sg-ssh', {
vpcId: vpc.id,
ingress: [
{ protocol: 'tcp', fromPort: 22, toPort: 22, cidrBlocks: ['0.0.0.0/0'] }
],
]
})

// HTTP security group
const http = new aws.ec2.SecurityGroup('beet-bot-sg-http', {
vpcId: vpc.id,
egress: [
{ protocol: 'tcp', fromPort: 80, toPort: 80, cidrBlocks: ['0.0.0.0/0'] },
{ protocol: 'tcp', fromPort: 443, toPort: 443, cidrBlocks: ['0.0.0.0/0'] }
Expand Down Expand Up @@ -119,11 +124,18 @@ const instance = new aws.ec2.Instance('beet-bot', {
instanceType: 't2.micro', // Available in the AWS free tier
ami: 'ami-0022f774911c1d690', // Latest amazon linux AMI
subnetId: subnet.id,
vpcSecurityGroupIds: [group.id],
vpcSecurityGroupIds: [ssh.id, http.id],
iamInstanceProfile: new aws.iam.InstanceProfile('beet-bot-profile', { role: policy.role }),
userData: cloudConfig,
userDataReplaceOnChange: true
})

// EC2 Instance connect endpoint
const ice = new aws.ec2transitgateway.InstanceConnectEndpoint('beet-bot-ice', {
subnetId: subnet.id,
securityGroupIds: [ssh.id]
})

export const instanceId = instance.id
export const rtaId = rta.id
export const rtbAssocId = rtbAssoc.id
export const iceId = ice.id

0 comments on commit e3e3324

Please sign in to comment.