Skip to content

Commit

Permalink
Vpc: use bastion AMI from correct region
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Sep 19, 2024
1 parent 47bd118 commit 8838261
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions platform/src/components/aws/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,12 @@ export class Vpc extends Component implements Link.Linkable {
this.cloudmapNamespace = cloudmapNamespace;

function normalizeAz() {
const zones = getAvailabilityZonesOutput({
state: "available",
});
const zones = getAvailabilityZonesOutput(
{
state: "available",
},
{ parent },
);
return all([zones, args?.az ?? 2]).apply(([zones, az]) =>
Array(az)
.fill(0)
Expand Down Expand Up @@ -498,23 +501,29 @@ export class Vpc extends Component implements Link.Linkable {
{ role: role.name },
{ parent },
);
const amiIds = ec2.getAmiIdsOutput(
{
owners: ["amazon"],
filters: [
{
name: "name",
// The AMI has the SSM agent pre-installed
values: ["al2023-ami-2023.5.20240916.0-kernel-6.1-x86_64"],
},
],
},
{ parent },
).ids;
return new ec2.Instance(
...transform(
args?.transform?.bastionInstance,
`${name}BastionInstance`,
{
instanceType: "t2.micro",
ami: "ami-0427090fd1714168b",
ami: amiIds.apply((ids) => ids[0]),
subnetId: publicSubnets.apply((v) => v[0].id),
vpcSecurityGroupIds: [sg.id],
iamInstanceProfile: instanceProfile.name,
userData: [
`#!/bin/bash`,
`set -ex`,
`sudo yum install -y amazon-ssm-agent`,
`sudo systemctl enable amazon-ssm-agent`,
`sudo systemctl start amazon-ssm-agent`,
].join("\n"),
tags: {
"sst:lookup-type": "bastion",
},
Expand Down

0 comments on commit 8838261

Please sign in to comment.