mysterious-family-43099
04/27/2023, 5:13 PMinterface CreateEc2InstanceArgs {
name: string;
stackName: string;
instanceType: string;
vpcId: pulumi.Output<string>;
isPublic: boolean;
enableHttp: boolean;
sshPublicKey: string;
rootBlockDevice: aws.types.input.ec2.InstanceRootBlockDevice;
amiName?: string;
userData?: string;
useEip?: boolean;
}
const instance = new aws.ec2.Instance(instanceName, {
instanceType,
// For now we are assuming that if the EC2 instance is public then we want a public IP.
// This may not necessarily be true if we put it behind a load balancer.
subnetId,
iamInstanceProfile,
keyName: keyPair.keyName,
associatePublicIpAddress: isPublic,
rootBlockDevice: {
...rootBlockDevice,
tags: { Name: volumeName, Stack: stackName },
},
vpcSecurityGroupIds: [securityGroup.id],
...(userData && { userData }),
ami: ami.id,
tags: { Name: instanceName, Stack: stackName },
});