feat: changed ec2 module and updated readme
This commit is contained in:
@@ -8,23 +8,27 @@
|
||||
# }
|
||||
|
||||
module "TestInstance" {
|
||||
source = "../../../modules/compute/ec2"
|
||||
source = "terraform-aws-modules/ec2-instance/aws"
|
||||
version = "6.2.0"
|
||||
|
||||
additional-tags = {}
|
||||
ami-id = data.aws_ami.this.id
|
||||
asso-eip = false
|
||||
asso-public-ip = false
|
||||
data-volumes = {}
|
||||
instance-name = "TestInstance001"
|
||||
instance-type = "t4g.large"
|
||||
kms-key-id = module.KmsKeys.cmks["allpurpose"].arn
|
||||
root-volume-size = 20
|
||||
security-groups = []
|
||||
subnet-id = data.terraform_remote_state.vpc.outputs.private_subnets[0]
|
||||
user-data = <<EOF
|
||||
#!/bin/bash
|
||||
dnf -y install git
|
||||
EOF
|
||||
ami = data.aws_ami.this.id
|
||||
associate_public_ip_address = false
|
||||
create_eip = false
|
||||
name = "TestInstance001"
|
||||
instance_type = "t4g.large"
|
||||
subnet_id = data.terraform_remote_state.vpc.outputs.private_subnets[0]
|
||||
create_security_group = false
|
||||
root_block_device = {
|
||||
device_name = "/dev/xvda"
|
||||
type = "gp3"
|
||||
size = 20
|
||||
delete_on_termination = true
|
||||
kms_key_id = module.KmsKeys.cmks["allpurpose"].arn
|
||||
}
|
||||
metadata_options = {
|
||||
http_put_response_hop_limit = 2
|
||||
http_tokens = "required"
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_ami" "this" {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
output "instance_info" {
|
||||
value = module.TestInstance.ec2-id-ip
|
||||
value = {
|
||||
id = module.TestInstance.id,
|
||||
private_ip = module.TestInstance.private_ip
|
||||
}
|
||||
}
|
||||
@@ -60,4 +60,8 @@ For example, vpc with ipv6 could not be created. It failed with the following er
|
||||
│ on .terraform/modules/vpc/main.tf line 293, in resource "aws_subnet" "private":
|
||||
│ 293: resource "aws_subnet" "private" {
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
Also, ec2 instance's associate_public_ip_address attribute is always set to true, despite
|
||||
it is set to false in my code. This caused the instance to be redeployed everytime terraform
|
||||
apply is ran.
|
||||
Reference in New Issue
Block a user