Evidence create & Destroy AWS Resources
Melakukan checking resources apa saja yang akan dibuat
terraform plan -out=tfplan
widianto@ID-LPT-073:~/terraform$ terraform plan -out=tfplan
data.aws_vpc.default: Reading...
data.aws_vpc.default: Read complete after 1s [id=vpc-018916e773db7d4bc]
data.aws_subnets.default: Reading...
data.aws_subnets.default: Read complete after 0s [id=ap-southeast-1]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_db_instance.mysql will be created
+ resource "aws_db_instance" "mysql" {
+ address = (known after apply)
+ allocated_storage = 20
+ apply_immediately = false
+ arn = (known after apply)
+ auto_minor_version_upgrade = true
+ availability_zone = (known after apply)
+ backup_retention_period = 0
+ backup_target = (known after apply)
+ backup_window = (known after apply)
+ ca_cert_identifier = (known after apply)
+ character_set_name = (known after apply)
+ copy_tags_to_snapshot = false
+ database_insights_mode = (known after apply)
+ db_name = "webappdb"
+ db_subnet_group_name = "default-subnet-group"
+ dedicated_log_volume = false
+ delete_automated_backups = true
+ domain_fqdn = (known after apply)
+ endpoint = (known after apply)
+ engine = "mysql"
+ engine_lifecycle_support = (known after apply)
+ engine_version = "8.0.35"
+ engine_version_actual = (known after apply)
+ hosted_zone_id = (known after apply)
+ id = (known after apply)
+ identifier = (known after apply)
+ identifier_prefix = (known after apply)
+ instance_class = "db.t3.micro"
+ iops = (known after apply)
+ kms_key_id = (known after apply)
+ latest_restorable_time = (known after apply)
+ license_model = (known after apply)
+ listener_endpoint = (known after apply)
+ maintenance_window = (known after apply)
+ master_user_secret = (known after apply)
+ master_user_secret_kms_key_id = (known after apply)
+ monitoring_interval = 0
+ monitoring_role_arn = (known after apply)
+ multi_az = (known after apply)
+ nchar_character_set_name = (known after apply)
+ network_type = (known after apply)
+ option_group_name = (known after apply)
+ parameter_group_name = (known after apply)
+ password = (sensitive value)
+ password_wo = (write-only attribute)
+ performance_insights_enabled = false
+ performance_insights_kms_key_id = (known after apply)
+ performance_insights_retention_period = (known after apply)
+ port = (known after apply)
+ publicly_accessible = false
+ replica_mode = (known after apply)
+ replicas = (known after apply)
+ resource_id = (known after apply)
+ skip_final_snapshot = true
+ snapshot_identifier = (known after apply)
+ status = (known after apply)
+ storage_throughput = (known after apply)
+ storage_type = (known after apply)
+ tags_all = (known after apply)
+ timezone = (known after apply)
+ username = "tempAdmin"
+ vpc_security_group_ids = (known after apply)
}
# aws_db_subnet_group.default will be created
+ resource "aws_db_subnet_group" "default" {
+ arn = (known after apply)
+ description = "Managed by Terraform"
+ id = (known after apply)
+ name = "default-subnet-group"
+ name_prefix = (known after apply)
+ subnet_ids = [
+ "subnet-0627e628bcb79ad97",
+ "subnet-0771971a020b2903f",
+ "subnet-0b4aeebd98aa4c1d4",
]
+ supported_network_types = (known after apply)
+ tags_all = (known after apply)
+ vpc_id = (known after apply)
}
# aws_instance.web will be created
+ resource "aws_instance" "web" {
+ ami = "ami-0c1907b6d738188e5"
+ arn = (known after apply)
+ associate_public_ip_address = (known after apply)
+ availability_zone = (known after apply)
+ cpu_core_count = (known after apply)
+ cpu_threads_per_core = (known after apply)
+ disable_api_stop = (known after apply)
+ disable_api_termination = (known after apply)
+ ebs_optimized = (known after apply)
+ enable_primary_ipv6 = (known after apply)
+ get_password_data = false
+ host_id = (known after apply)
+ host_resource_group_arn = (known after apply)
+ iam_instance_profile = (known after apply)
+ id = (known after apply)
+ instance_initiated_shutdown_behavior = (known after apply)
+ instance_lifecycle = (known after apply)
+ instance_state = (known after apply)
+ instance_type = "t2.micro"
+ ipv6_address_count = (known after apply)
+ ipv6_addresses = (known after apply)
+ key_name = "wid"
+ monitoring = (known after apply)
+ outpost_arn = (known after apply)
+ password_data = (known after apply)
+ placement_group = (known after apply)
+ placement_partition_number = (known after apply)
+ primary_network_interface_id = (known after apply)
+ private_dns = (known after apply)
+ private_ip = (known after apply)
+ public_dns = (known after apply)
+ public_ip = (known after apply)
+ secondary_private_ips = (known after apply)
+ security_groups = (known after apply)
+ source_dest_check = true
+ spot_instance_request_id = (known after apply)
+ subnet_id = "subnet-0627e628bcb79ad97"
+ tags = {
+ "Name" = "WebAppInstance"
}
+ tags_all = {
+ "Name" = "WebAppInstance"
}
+ tenancy = (known after apply)
+ user_data = (known after apply)
+ user_data_base64 = (known after apply)
+ user_data_replace_on_change = false
+ vpc_security_group_ids = (known after apply)
+ capacity_reservation_specification (known after apply)
+ cpu_options (known after apply)
+ ebs_block_device (known after apply)
+ enclave_options (known after apply)
+ ephemeral_block_device (known after apply)
+ instance_market_options (known after apply)
+ maintenance_options (known after apply)
+ metadata_options (known after apply)
+ network_interface (known after apply)
+ private_dns_name_options (known after apply)
+ root_block_device (known after apply)
}
# aws_s3_bucket.app_bucket will be created
+ resource "aws_s3_bucket" "app_bucket" {
+ acceleration_status = (known after apply)
+ acl = (known after apply)
+ arn = (known after apply)
+ bucket = (known after apply)
+ bucket_domain_name = (known after apply)
+ bucket_prefix = (known after apply)
+ bucket_regional_domain_name = (known after apply)
+ force_destroy = true
+ hosted_zone_id = (known after apply)
+ id = (known after apply)
+ object_lock_enabled = (known after apply)
+ policy = (known after apply)
+ region = (known after apply)
+ request_payer = (known after apply)
+ tags_all = (known after apply)
+ website_domain = (known after apply)
+ website_endpoint = (known after apply)
+ cors_rule (known after apply)
+ grant (known after apply)
+ lifecycle_rule (known after apply)
+ logging (known after apply)
+ object_lock_configuration (known after apply)
+ replication_configuration (known after apply)
+ server_side_encryption_configuration (known after apply)
+ versioning (known after apply)
+ website (known after apply)
}
# aws_security_group.web_sg will be created
+ resource "aws_security_group" "web_sg" {
+ arn = (known after apply)
+ description = "Allow HTTP, HTTPS, SSH, MySQL"
+ egress = [
+ {
+ cidr_blocks = [
+ "0.0.0.0/0",
]
+ from_port = 0
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "-1"
+ security_groups = []
+ self = false
+ to_port = 0
# (1 unchanged attribute hidden)
},
]
+ id = (known after apply)
+ ingress = [
+ {
+ cidr_blocks = [
+ "0.0.0.0/0",
]
+ from_port = 22
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "tcp"
+ security_groups = []
+ self = false
+ to_port = 22
# (1 unchanged attribute hidden)
},
+ {
+ cidr_blocks = [
+ "0.0.0.0/0",
]
+ from_port = 443
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "tcp"
+ security_groups = []
+ self = false
+ to_port = 443
# (1 unchanged attribute hidden)
},
+ {
+ cidr_blocks = [
+ "0.0.0.0/0",
]
+ from_port = 80
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "tcp"
+ security_groups = []
+ self = false
+ to_port = 80
# (1 unchanged attribute hidden)
},
+ {
+ cidr_blocks = []
+ from_port = 3306
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "tcp"
+ security_groups = []
+ self = true
+ to_port = 3306
# (1 unchanged attribute hidden)
},
]
+ name = "web-sg"
+ name_prefix = (known after apply)
+ owner_id = (known after apply)
+ revoke_rules_on_delete = false
+ tags_all = (known after apply)
+ vpc_id = "vpc-018916e773db7d4bc"
}
# random_id.bucket_id will be created
+ resource "random_id" "bucket_id" {
+ b64_std = (known after apply)
+ b64_url = (known after apply)
+ byte_length = 4
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
}
Plan: 6 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ ec2_public_ip = (known after apply)
+ rds_endpoint = (known after apply)
+ s3_bucket_name = (known after apply)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Saved the plan to: tfplan
To perform exactly these actions, run the following command to apply:
terraform apply "tfplan"
Setelah pasti lakukan terraform apply untuk eksekusi
terraform apply tfplan
widianto@ID-LPT-073:~/terraform$ terraform apply tfplan
random_id.bucket_id: Creating...
random_id.bucket_id: Creation complete after 0s [id=kaGVJw]
aws_db_subnet_group.default: Creating...
aws_s3_bucket.app_bucket: Creating...
aws_security_group.web_sg: Creating...
aws_db_subnet_group.default: Creation complete after 1s [id=default-subnet-group]
aws_s3_bucket.app_bucket: Creation complete after 3s [id=my-webapp-bucket-91a19527]
aws_security_group.web_sg: Creation complete after 3s [id=sg-0e3968c482a1254cd]
aws_db_instance.mysql: Creating...
aws_instance.web: Creating...
aws_db_instance.mysql: Still creating... [10s elapsed]
aws_instance.web: Still creating... [10s elapsed]
aws_instance.web: Creation complete after 13s [id=i-0dcc7f7c60e08f3bc]
aws_db_instance.mysql: Still creating... [20s elapsed]
aws_db_instance.mysql: Still creating... [30s elapsed]
aws_db_instance.mysql: Still creating... [40s elapsed]
aws_db_instance.mysql: Still creating... [50s elapsed]
aws_db_instance.mysql: Still creating... [1m0s elapsed]
aws_db_instance.mysql: Still creating... [1m10s elapsed]
aws_db_instance.mysql: Still creating... [1m20s elapsed]
aws_db_instance.mysql: Still creating... [1m30s elapsed]
aws_db_instance.mysql: Still creating... [1m40s elapsed]
aws_db_instance.mysql: Still creating... [1m50s elapsed]
aws_db_instance.mysql: Still creating... [2m0s elapsed]
aws_db_instance.mysql: Still creating... [2m10s elapsed]
aws_db_instance.mysql: Still creating... [2m20s elapsed]
aws_db_instance.mysql: Still creating... [2m30s elapsed]
aws_db_instance.mysql: Still creating... [2m40s elapsed]
aws_db_instance.mysql: Still creating... [2m50s elapsed]
aws_db_instance.mysql: Still creating... [3m0s elapsed]
aws_db_instance.mysql: Creation complete after 3m3s [id=db-T6BOPBNQ5QZW2YROKIMEFWKA7Q]
Apply complete! Resources: 6 added, 0 changed, 0 destroyed.
Outputs:
ec2_public_ip = "13.212.122.63"
rds_endpoint = "terraform-20250429021147512700000001.c5ya80m00geq.ap-southeast-1.rds.amazonaws.com:3306"
s3_bucket_name = "my-webapp-bucket-91a19527"
=======================================================================================
EC2 Instance
S3-Bucket
RDS
No Comments