Skip to content

Commit f5bd801

Browse files
author
Your Name
committed
mod exe08 src
1 parent 94666c9 commit f5bd801

File tree

9 files changed

+143
-91
lines changed

9 files changed

+143
-91
lines changed

08-input-vars-locals-outputs/.terraform.lock.hcl

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-input-vars-locals-outputs/compute.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ data "aws_ami" "ubuntu" {
1313
}
1414
}
1515

16+
resource "aws_instance" "compute" {
17+
ami = data.aws_ami.ubuntu.id
18+
instance_type = var.ec2_instance_type
19+
20+
root_block_device {
21+
delete_on_termination = true
22+
volume_size = var.ec2_volume_size
23+
volume_type = var.ec2_volume_type
24+
}
25+
26+
}
27+
28+
29+
30+
31+
1632
# resource "aws_instance" "compute" {
1733
# ami = data.aws_ami.ubuntu.id
1834
# instance_type = var.ec2_instance_type
@@ -24,4 +40,4 @@ data "aws_ami" "ubuntu" {
2440
# }
2541

2642
# tags = merge(local.common_tags, var.additional_tags)
27-
# }
43+
# }
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
output "s3_bucket_name" {
2-
value = aws_s3_bucket.project_bucket.bucket
3-
sensitive = true
4-
description = "The name of the S3 bucket"
5-
}
1+
# output "s3_bucket_name" {
2+
# value = aws_s3_bucket.project_bucket.bucket
3+
# sensitive = true
4+
# description = "The name of the S3 bucket"
5+
# }
66

7-
output "sensitive_var" {
8-
sensitive = true
9-
value = var.my_sensitive_value
10-
}
7+
# output "sensitive_var" {
8+
# sensitive = true
9+
# value = var.my_sensitive_value
10+
# }
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
additional_tags = {
2-
ValuesFrom = "override.tfvars"
3-
}
1+
# additional_tags = {
2+
# ValuesFrom = "override.tfvars"
3+
# }

08-input-vars-locals-outputs/provider.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ terraform {
1111
version = "~> 3.0"
1212
}
1313
}
14+
backend "s3" {
15+
bucket = "terraform-test-mario-remote-backend"
16+
key = "04-backends/dev/state.tfstate"
17+
region = "ap-northeast-2"
18+
}
19+
1420
}
1521

22+
# AMI ID(ap-northeast-2) : ami-0572f73f0a5650b33
23+
# AMI ID(us-east-2) : ami-034de852f74caf71b
24+
25+
1626
provider "aws" {
17-
region = "eu-west-1"
18-
}
27+
region = "ap-northeast-2"
28+
}

08-input-vars-locals-outputs/s3.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
resource "random_id" "project_bucket_suffix" {
2-
byte_length = 4
3-
}
1+
# resource "random_id" "project_bucket_suffix" {
2+
# byte_length = 4
3+
# }
44

5-
resource "aws_s3_bucket" "project_bucket" {
6-
bucket = "${local.project}-${random_id.project_bucket_suffix.hex}"
5+
# resource "aws_s3_bucket" "project_bucket" {
6+
# bucket = "${local.project}-${random_id.project_bucket_suffix.hex}"
77

8-
tags = merge(local.common_tags, var.additional_tags)
9-
}
8+
# tags = merge(local.common_tags, var.additional_tags)
9+
# }
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
locals {
2-
project = "08-input-vars-locals-outputs"
3-
project_owner = "terraform-course"
4-
cost_center = "1234"
5-
managed_by = "Terraform"
6-
}
1+
# locals {
2+
# project = "08-input-vars-locals-outputs"
3+
# project_owner = "terraform-course"
4+
# cost_center = "1234"
5+
# managed_by = "Terraform"
6+
# }
77

8-
locals {
9-
common_tags = {
10-
project = local.project
11-
project_owner = local.project_owner
12-
cost_center = local.cost_center
13-
managed_by = local.managed_by
14-
sensitive_tag = var.my_sensitive_value
15-
}
16-
}
8+
# locals {
9+
# common_tags = {
10+
# project = local.project
11+
# project_owner = local.project_owner
12+
# cost_center = local.cost_center
13+
# managed_by = local.managed_by
14+
# sensitive_tag = var.my_sensitive_value
15+
# }
16+
# }
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
ec2_instance_type = "t2.micro"
1+
# ec2_instance_type = "t2.micro"
22

3-
ec2_volume_config = {
4-
size = 10
5-
type = "gp2"
6-
}
3+
# ec2_volume_config = {
4+
# size = 10
5+
# type = "gp2"
6+
# }
77

8-
additional_tags = {
9-
ValuesFrom = "terraform.tfvars"
10-
}
8+
# additional_tags = {
9+
# ValuesFrom = "terraform.tfvars"
10+
# }
Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,58 @@
11
variable "ec2_instance_type" {
22
type = string
33
description = "The type of the managed EC2 instances."
4+
default = "t2.micro"
45

56
validation {
67
condition = contains(["t2.micro", "t3.micro"], var.ec2_instance_type)
78
error_message = "Only supports t2.micro and t3.micro"
9+
810
}
11+
912
}
1013

11-
variable "ec2_volume_config" {
12-
type = object({
13-
size = number
14-
type = string
15-
})
16-
description = "The size and type of the root block volume for EC2 instances."
14+
variable "ec2_volume_size" {
15+
type = number
16+
description = "The size in GB of the root block volume attached to managed EC2 instances."
17+
#default = 10
1718

18-
default = {
19-
size = 10
20-
type = "gp3"
21-
}
2219
}
2320

24-
variable "additional_tags" {
25-
type = map(string)
26-
default = {}
21+
variable "ec2_volume_type" {
22+
type = string
23+
description = "The volume type between gp2 and gp3"
2724
}
2825

29-
variable "my_sensitive_value" {
30-
type = string
31-
sensitive = true
32-
}
26+
27+
# variable "ec2_instance_type" {
28+
# type = string
29+
# description = "The type of the managed EC2 instances."
30+
31+
# validation {
32+
# condition = contains(["t2.micro", "t3.micro"], var.ec2_instance_type)
33+
# error_message = "Only supports t2.micro and t3.micro"
34+
# }
35+
# }
36+
37+
# variable "ec2_volume_config" {
38+
# type = object({
39+
# size = number
40+
# type = string
41+
# })
42+
# description = "The size and type of the root block volume for EC2 instances."
43+
44+
# default = {
45+
# size = 10
46+
# type = "gp3"
47+
# }
48+
# }
49+
50+
# variable "additional_tags" {
51+
# type = map(string)
52+
# default = {}
53+
# }
54+
55+
# variable "my_sensitive_value" {
56+
# type = string
57+
# sensitive = true
58+
# }

0 commit comments

Comments
 (0)