Moved creation of the instance after database creation
All checks were successful
AWS Deploy on Push / build (push) Successful in 6m51s
All checks were successful
AWS Deploy on Push / build (push) Successful in 6m51s
This commit is contained in:
@@ -111,32 +111,6 @@ class IptvManagerStack(Stack):
|
||||
iam.ManagedPolicy.from_aws_managed_policy_name("AmazonCognitoReadOnly")
|
||||
)
|
||||
|
||||
# EC2 Instance
|
||||
instance = ec2.Instance(
|
||||
self,
|
||||
"IptvManagerInstance",
|
||||
vpc=vpc,
|
||||
vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC),
|
||||
instance_type=ec2.InstanceType.of(
|
||||
ec2.InstanceClass.T2, ec2.InstanceSize.MICRO
|
||||
),
|
||||
machine_image=ec2.AmazonLinuxImage(
|
||||
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023
|
||||
),
|
||||
security_group=security_group,
|
||||
key_pair=key_pair,
|
||||
role=role,
|
||||
# Option: 1: Enable auto-assign public IP (free tier compatible)
|
||||
associate_public_ip_address=True,
|
||||
)
|
||||
|
||||
# Option: 2: Create Elastic IP (not free tier compatible)
|
||||
# eip = ec2.CfnEIP(
|
||||
# self, "IptvManagerEIP",
|
||||
# domain="vpc",
|
||||
# instance_id=instance.instance_id
|
||||
# )
|
||||
|
||||
# Add Cognito User Pool
|
||||
user_pool = cognito.UserPool(
|
||||
self,
|
||||
@@ -282,6 +256,32 @@ class IptvManagerStack(Stack):
|
||||
iam.ManagedPolicy.from_aws_managed_policy_name("AmazonSSMReadOnlyAccess")
|
||||
)
|
||||
|
||||
# EC2 Instance (created after all dependencies are ready)
|
||||
instance = ec2.Instance(
|
||||
self,
|
||||
"IptvManagerInstance",
|
||||
vpc=vpc,
|
||||
vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC),
|
||||
instance_type=ec2.InstanceType.of(
|
||||
ec2.InstanceClass.T2, ec2.InstanceSize.MICRO
|
||||
),
|
||||
machine_image=ec2.AmazonLinuxImage(
|
||||
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023
|
||||
),
|
||||
security_group=security_group,
|
||||
key_pair=key_pair,
|
||||
role=role,
|
||||
# Option: 1: Enable auto-assign public IP (free tier compatible)
|
||||
associate_public_ip_address=True,
|
||||
)
|
||||
|
||||
# Option: 2: Create Elastic IP (not free tier compatible)
|
||||
# eip = ec2.CfnEIP(
|
||||
# self, "IptvManagerEIP",
|
||||
# domain="vpc",
|
||||
# instance_id=instance.instance_id
|
||||
# )
|
||||
|
||||
# Update instance with userdata
|
||||
instance.add_user_data(userdata.render())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user