Skip to content

Commit 2d05e60

Browse files
committed
Open http ports for ec2 for ssm to work
1 parent a533bc0 commit 2d05e60

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

src/components/ec2-ssm-connect.ts

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ export class Ec2SSMConnect extends pulumi.ComponentResource {
3737
toPort: 22,
3838
cidrBlocks: ['0.0.0.0/0'],
3939
},
40+
{
41+
protocol: 'tcp',
42+
fromPort: 80,
43+
toPort: 80,
44+
cidrBlocks: ['0.0.0.0/0'],
45+
},
46+
{
47+
protocol: 'tcp',
48+
fromPort: 443,
49+
toPort: 443,
50+
cidrBlocks: ['0.0.0.0/0'],
51+
},
4052
],
4153
egress: [
4254
{ protocol: '-1', fromPort: 0, toPort: 0, cidrBlocks: ['0.0.0.0/0'] },
@@ -82,6 +94,31 @@ export class Ec2SSMConnect extends pulumi.ComponentResource {
8294
{ parent: this, dependsOn: [ssmPolicyAttachment] },
8395
);
8496

97+
this.sshKeyPair = new aws.ec2.KeyPair(
98+
`${name}-ec2-keypair`,
99+
{
100+
publicKey: args.sshPublicKey,
101+
},
102+
{ parent: this },
103+
);
104+
105+
this.ec2 = new aws.ec2.Instance(
106+
`${name}-ec2`,
107+
{
108+
ami: 'ami-067d1e60475437da2',
109+
associatePublicIpAddress: false,
110+
instanceType: 't2.micro',
111+
keyName: this.sshKeyPair.keyName,
112+
iamInstanceProfile: ssmProfile.name,
113+
subnetId,
114+
vpcSecurityGroupIds: [this.ec2SecurityGroup.id],
115+
tags: {
116+
Name: `${name}-ec2`,
117+
},
118+
},
119+
{ parent: this },
120+
);
121+
85122
this.ssmVpcEndpoint = new aws.ec2.VpcEndpoint(
86123
`${name}-ssm-vpc-endpoint`,
87124
{
@@ -93,7 +130,7 @@ export class Ec2SSMConnect extends pulumi.ComponentResource {
93130
securityGroupIds: [this.ec2SecurityGroup.id],
94131
privateDnsEnabled: true,
95132
},
96-
{ parent: this },
133+
{ parent: this, dependsOn: [this.ec2] },
97134
);
98135

99136
this.ec2MessagesVpcEndpoint = new aws.ec2.VpcEndpoint(
@@ -107,7 +144,7 @@ export class Ec2SSMConnect extends pulumi.ComponentResource {
107144
securityGroupIds: [this.ec2SecurityGroup.id],
108145
privateDnsEnabled: true,
109146
},
110-
{ parent: this },
147+
{ parent: this, dependsOn: [this.ec2] },
111148
);
112149

113150
this.ssmMessagesVpcEndpoint = new aws.ec2.VpcEndpoint(
@@ -121,32 +158,7 @@ export class Ec2SSMConnect extends pulumi.ComponentResource {
121158
securityGroupIds: [this.ec2SecurityGroup.id],
122159
privateDnsEnabled: true,
123160
},
124-
{ parent: this },
125-
);
126-
127-
this.sshKeyPair = new aws.ec2.KeyPair(
128-
`${name}-ec2-keypair`,
129-
{
130-
publicKey: args.sshPublicKey,
131-
},
132-
{ parent: this },
133-
);
134-
135-
this.ec2 = new aws.ec2.Instance(
136-
`${name}-ec2`,
137-
{
138-
ami: 'ami-067d1e60475437da2',
139-
associatePublicIpAddress: false,
140-
instanceType: 't2.micro',
141-
keyName: this.sshKeyPair.keyName,
142-
iamInstanceProfile: ssmProfile.name,
143-
subnetId,
144-
vpcSecurityGroupIds: [this.ec2SecurityGroup.id],
145-
tags: {
146-
Name: `${name}-ec2`,
147-
},
148-
},
149-
{ parent: this },
161+
{ parent: this, dependsOn: [this.ec2] },
150162
);
151163

152164
this.registerOutputs();

0 commit comments

Comments
 (0)