File tree Expand file tree Collapse file tree 9 files changed +90
-44
lines changed
Expand file tree Collapse file tree 9 files changed +90
-44
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,22 +4,36 @@ module "dev-app" {
44 source = " ./my_app_infra_module"
55 my_env = " dev"
66 instance_type = " t2.micro"
7- ami = " ami-007855ac798b5175e "
7+ ami = " ami-0e9085e60087ce171 "
88}
99
1010# prd
1111module "prd-app" {
1212 source = " ./my_app_infra_module"
1313 my_env = " prd"
1414 instance_type = " t2.medium"
15- ami = " ami-007855ac798b5175e "
15+ ami = " ami-0e9085e60087ce171 "
1616}
1717
1818# stg
1919module "stg-app" {
2020 source = " ./my_app_infra_module"
2121 my_env = " stg"
2222 instance_type = " t2.small"
23- ami = " ami-007855ac798b5175e "
23+ ami = " ami-0e9085e60087ce171 "
2424
25+ }
26+ output "dev_app_public_ips" {
27+ value = module. dev-app . ec2_instances_public_ips
28+ description = " Public IPs of the dev environment EC2 instances"
29+ }
30+
31+ output "prd_app_public_ips" {
32+ value = module. prd-app . ec2_instances_public_ips
33+ description = " Public IPs of the prd environment EC2 instances"
34+ }
35+
36+ output "stg_app_public_ips" {
37+ value = module. stg-app . ec2_instances_public_ips
38+ description = " Public IPs of the stg environment EC2 instances"
2539}
Original file line number Diff line number Diff line change 1+ output "ec2_instances_public_ips" {
2+ value = aws_instance. my_app_server [* ]. public_ip
3+ description = " Public IP addresses of the EC2 instances"
4+ }
Original file line number Diff line number Diff line change 1+ resource "aws_key_pair" "deployer" {
2+ key_name = " ${ var . my_env } -terra-automate-key"
3+ public_key = file (" terra-key.pub" )
4+
5+ }
6+
7+ resource "aws_default_vpc" "default" {
8+
9+ }
10+
11+ resource "aws_security_group" "allow_user_to_connect" {
12+ name = " ${ var . my_env } -allow-TLS"
13+ description = " Allow user to connect"
14+ vpc_id = aws_default_vpc. default . id
15+ ingress {
16+ description = " port 22 allow"
17+ from_port = 22
18+ to_port = 22
19+ protocol = " tcp"
20+ cidr_blocks = [" 0.0.0.0/0" ]
21+ }
22+
23+ egress {
24+ description = " allow all outgoing traffic "
25+ from_port = 0
26+ to_port = 0
27+ protocol = " -1"
28+ cidr_blocks = [" 0.0.0.0/0" ]
29+ }
30+
31+ ingress {
32+ description = " port 80 allow"
33+ from_port = 80
34+ to_port = 80
35+ protocol = " tcp"
36+ cidr_blocks = [" 0.0.0.0/0" ]
37+ }
38+
39+ ingress {
40+ description = " port 443 allow"
41+ from_port = 443
42+ to_port = 443
43+ protocol = " tcp"
44+ cidr_blocks = [" 0.0.0.0/0" ]
45+ }
46+
47+ tags = {
48+ Name = " ${ var . my_env } -mysecurity"
49+ }
50+ }
51+
152resource "aws_instance" "my_app_server" {
253 count = 2
354 ami = var. ami
455 instance_type = var. instance_type
56+ key_name = aws_key_pair. deployer . key_name
57+ security_groups = [aws_security_group . allow_user_to_connect . name ]
58+ root_block_device {
59+ volume_size = 10
60+ volume_type = " gp3"
61+ }
562 tags = {
663 Name = " ${ var . my_env } -tws-demo-app-server"
764 }
Original file line number Diff line number Diff line change 1+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHgXqutmPuLFCDk1TAiKgusEp/1E35SFEz+x0GzvUR4e
[email protected]
Original file line number Diff line number Diff line change 11provider "aws" {
2- region = var . aws_region
2+ region = " eu-west-1 "
33}
Original file line number Diff line number Diff line change 1+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHgXqutmPuLFCDk1TAiKgusEp/1E35SFEz+x0GzvUR4e
[email protected]
Original file line number Diff line number Diff line change @@ -5,10 +5,4 @@ terraform {
55 version = " 4.66.1"
66 }
77 }
8- backend "s3" {
9- bucket = " batch3-demo-state-bucket"
10- key = " terraform.tfstate"
11- region = " us-east-1"
12- dynamodb_table = " batch3-demo-state-table"
13- }
148}
Original file line number Diff line number Diff line change 1+ {
2+ "version" : 4 ,
3+ "terraform_version" : " 1.10.0" ,
4+ "serial" : 66 ,
5+ "lineage" : " 2ee018c5-3d26-1456-a70f-ba34c882e429" ,
6+ "outputs" : {},
7+ "resources" : [],
8+ "check_results" : null
9+ }
You can’t perform that action at this time.
0 commit comments