Recently I have been using aws-cdk to create EC2, VPC and S3 services.
But if I want to create my custom EC2 Library in python(not using JSII) than will be using aws_cdk's aws_ec2 library to actually create the EC2 Instance and a VPC.
The custom library will accept arguments like Instance Name(String) , InstanceType(String) , MachineImage(String) , Subnet Type (String)
Than this arguments will be refer like below:
Disclaimer: Code below Might not be correct
dummy_ec2 = ec2.Instance(self, <InstanceName>,
vpc=<Created_VPC>,
instance_type=ec2.InstanceType(<InstanceType>),
machine_image=ec2.AmazonLinuxImage(
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX,
edition=ec2.AmazonLinuxEdition.STANDARD,
virtualization=ec2.AmazonLinuxVirt.HVM,
storage=ec2.AmazonLinuxStorage.GENERAL_PURPOSE
),
key_name="demo-key",
vpc_subnets=ec2.SubnetSelection(subnet_type=<subnet_type>),
role=self.my_role
)
Any help Devs how to?