Skip to content

Instantly share code, notes, and snippets.

@youngsoul
Created March 7, 2022 19:01
Show Gist options
  • Save youngsoul/f313c07516669052d797b2a1cc75f6f4 to your computer and use it in GitHub Desktop.
Save youngsoul/f313c07516669052d797b2a1cc75f6f4 to your computer and use it in GitHub Desktop.
CDK EC2 Instance Example
self.bastion_host = ec2.Instance(self, id=f'{resources_prefix}-bastion-host',
instance_type=ec2.InstanceType(instance_type_identifier='t2.micro'),
machine_image=ec2.AmazonLinuxImage(
edition=ec2.AmazonLinuxEdition.STANDARD,
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
virtualization=ec2.AmazonLinuxVirt.HVM,
storage=ec2.AmazonLinuxStorage.GENERAL_PURPOSE
),
vpc=self.vpc,
key_name='pryan-aws', # must create the key name manually first
vpc_subnets=ec2.SubnetSelection(
subnet_type=ec2.SubnetType.PUBLIC
),
security_group=self.bastion_sg
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment