Skip to content

Commit

Permalink
Update sds tf
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jul 24, 2024
1 parent c152f01 commit df16a71
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 265 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
*__pycache__

sessions
.terraform/
.terraform.lock.hcl

#tools
58 changes: 0 additions & 58 deletions sds/unity/terraform/bk.tf

This file was deleted.

99 changes: 0 additions & 99 deletions sds/unity/terraform/main.tf

This file was deleted.

File renamed without changes.
44 changes: 44 additions & 0 deletions sds/unity/terraform/modules/ec2-docker/bk.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
locals {
block_device_path = "/dev/sdh"
}

resource "aws_iam_instance_profile" "unity_mmgis_instance_profile" {
name = "unity-mmgis-instance-profile-tf"

role = var.role

tags = {
Name = "unity_mmgis_instance_profile"
}
}

resource "aws_ebs_volume" "persistent" {
availability_zone = aws_instance.unity_mmgis_instance.availability_zone
size = var.persistent_volume_size_gb
}

resource "aws_volume_attachment" "persistent" {
device_name = local.block_device_path
volume_id = aws_ebs_volume.persistent.id
instance_id = aws_instance.unity_mmgis_instance.id
}


resource "aws_instance" "unity_mmgis_instance" {
ami = var.ami
instance_type = var.instance_type

tags = {
Name = "unity-mmgis-instance-tf"
}

key_name = var.key_name

vpc_security_group_ids = [var.sg_id]

subnet_id = var.subnet_id

iam_instance_profile = aws_iam_instance_profile.unity_mmgis_instance_profile.name

user_data = file("./modules/ec2-docker/add-mmgis.sh")
}
File renamed without changes.
18 changes: 18 additions & 0 deletions sds/unity/terraform/modules/ec2-docker/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
data "aws_ssm_parameter" "vpc_id" {
name = "/unity/account/network/vpc_id"
}

data "aws_ssm_parameter" "subnet_list" {
name = "/unity/account/network/subnet_list"
}

#data "aws_ssm_parameter" "u-cs-ecs" {
# name = "/unity/account/ecs/execution_role_arn"
#}


locals {
subnet_map = jsondecode(data.aws_ssm_parameter.subnet_list.value)
subnet_ids = nonsensitive(local.subnet_map["private"])
public_subnet_ids = nonsensitive(local.subnet_map["public"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,77 @@
# https://www.terraform.io/docs/providers/aws/r/instance.html
output "id" {
description = "The instance ID"
value = aws_instance.this.id
value = aws_instance.unity_mmgis_instance.id
}

output "arn" {
description = "The ARN of the instance"
value = aws_instance.this.arn
value = aws_instance.unity_mmgis_instance.arn
}

output "availability_zone" {
description = "The availability zone of the instance"
value = aws_instance.this.availability_zone
value = aws_instance.unity_mmgis_instance.availability_zone
}

output "placement_group" {
description = "The placement group of the instance"
value = aws_instance.this.placement_group
value = aws_instance.unity_mmgis_instance.placement_group
}

output "public_dns" {
description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC"
value = aws_instance.this.public_dns
value = aws_instance.unity_mmgis_instance.public_dns
}

output "public_ip" {
description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use public_ip, as this field will change after the EIP is attached."
value = aws_instance.this.public_ip
value = aws_instance.unity_mmgis_instance.public_ip
}

output "ipv6_addresses" {
description = "A list of assigned IPv6 addresses, if any"
value = aws_instance.this.ipv6_addresses
value = aws_instance.unity_mmgis_instance.ipv6_addresses
}

output "primary_network_interface_id" {
description = "The ID of the instance's primary network interface"
value = aws_instance.this.primary_network_interface_id
value = aws_instance.unity_mmgis_instance.primary_network_interface_id
}

output "private_dns" {
description = " The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC"
value = aws_instance.this.private_dns
value = aws_instance.unity_mmgis_instance.private_dns
}

output "private_ip" {
description = "The private IP address assigned to the instance"
value = aws_instance.this.private_ip
value = aws_instance.unity_mmgis_instance.private_ip
}

output "security_groups" {
description = " The associated security groups."
value = aws_instance.this.security_groups
value = aws_instance.unity_mmgis_instance.security_groups
}

output "vpc_security_group_ids" {
description = "The associated security groups in non-default VPC."
value = aws_instance.this.vpc_security_group_ids
value = aws_instance.unity_mmgis_instance.vpc_security_group_ids
}

output "subnet_id" {
description = "The VPC subnet ID."
value = aws_instance.this.subnet_id
value = aws_instance.unity_mmgis_instance.subnet_id
}

output "credit_specification" {
description = " Credit specification of instance."
value = aws_instance.this.credit_specification
value = aws_instance.unity_mmgis_instance.credit_specification
}

output "instance_state" {
description = "The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information."
value = aws_instance.this.instance_state
value = aws_instance.unity_mmgis_instance.instance_state
}

# TODO: This is a list with the `aws_instance` resource and we are just
Expand Down
Loading

0 comments on commit df16a71

Please sign in to comment.