From 55edaa68cffea545e5495c9a94797d2ab72e8dec Mon Sep 17 00:00:00 2001 From: Marnix Dessing Date: Tue, 23 May 2023 09:04:53 +0200 Subject: [PATCH] fix: add ec2 instance to check network connectivity --- src/ContainerCluster.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ContainerCluster.ts b/src/ContainerCluster.ts index a66ffc0..b06b7d6 100644 --- a/src/ContainerCluster.ts +++ b/src/ContainerCluster.ts @@ -27,9 +27,10 @@ export class ContainerClusterStack extends Stack { const hostedzone = this.importHostedZone(); const vpc = this.setupVpc(); const listner = this.setupLoadbalancer(vpc, hostedzone); - const cluster = this.constructEcsCluster(vpc); + this.constructEcsCluster(vpc); this.setupApiGateway(hostedzone, listner); - this.addIssueService(cluster, listner, props); + //this.addIssueService(cluster, listner, props); + this.setupEc2Instance(vpc); } setupVpc() { @@ -212,5 +213,19 @@ export class ContainerClusterStack extends Stack { } + setupEc2Instance(vpc: ec2.IVpc) { + const instance = new ec2.Instance(this, 'ec2-test-instance', { + vpc, + instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO), + machineImage: ec2.MachineImage.genericLinux({ + 'eu-central-1': 'ami-0452d2386670510e8', // Amazon linux 2023 AMI (ARM) + }), + vpcSubnets: { + subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS, + }, + }); + + instance.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore')); + } } \ No newline at end of file