From d72d5b81eb9e3af5d6f5efcbafa47f7a31fb2ab2 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 19 Jun 2024 12:22:07 +0530 Subject: [PATCH] learn(tf): learning provisioners --- AWS Automation/instance.tf | 22 +++++++++++++++++- AWS Automation/terraform.tfstate | 30 ++++++++++++------------- AWS Automation/terraform.tfstate.backup | 2 +- AWS Automation/test-folder/test.txt | 1 + 4 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 AWS Automation/test-folder/test.txt diff --git a/AWS Automation/instance.tf b/AWS Automation/instance.tf index a0ad806..58dad89 100644 --- a/AWS Automation/instance.tf +++ b/AWS Automation/instance.tf @@ -7,5 +7,25 @@ resource "aws_instance" "First-TF-Instance" { tags = { Name = "First-TF-Instance" } - user_data =file("${path.module}/script.sh") + user_data = file("${path.module}/script.sh") + + connection { + type = "ssh" + user = "ec2-user" + private_key = file("${path.module}/id_rsa") + host = self.public_ip + } + provisioner "file" { + source = "Readme.MD" + destination = "/tmp/Readme.MD" + } + provisioner "file" { + content = "This is test content" + destination = "/tmp/Content.MD" + } + provisioner "file" { + source = "test-folder" + destination = "/tmp/test-folder/" + } + } diff --git a/AWS Automation/terraform.tfstate b/AWS Automation/terraform.tfstate index 6e04f3b..a5277f0 100644 --- a/AWS Automation/terraform.tfstate +++ b/AWS Automation/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.8.5", - "serial": 67, + "serial": 105, "lineage": "c1e8351c-40a2-09a6-4b89-4bfb8790be4f", "outputs": { "keyName": { @@ -9,7 +9,7 @@ "type": "string" }, "securityGroupDetails": { - "value": "sg-0f720301a65b23bc6", + "value": "sg-0c493d9ce63a3a06f", "type": "string" } }, @@ -24,7 +24,7 @@ "schema_version": 1, "attributes": { "ami": "ami-0cc9838aa7ab1dce7", - "arn": "arn:aws:ec2:ap-south-1:454461993352:instance/i-000ea90ba9f868d8b", + "arn": "arn:aws:ec2:ap-south-1:454461993352:instance/i-0ff237011986a8ea8", "associate_public_ip_address": true, "availability_zone": "ap-south-1a", "capacity_reservation_specification": [ @@ -62,7 +62,7 @@ "host_id": "", "host_resource_group_arn": null, "iam_instance_profile": "", - "id": "i-000ea90ba9f868d8b", + "id": "i-0ff237011986a8ea8", "instance_initiated_shutdown_behavior": "stop", "instance_lifecycle": "", "instance_market_options": [], @@ -92,8 +92,8 @@ "password_data": "", "placement_group": "", "placement_partition_number": 0, - "primary_network_interface_id": "eni-0886c58ac6a018d8f", - "private_dns": "ip-172-31-42-89.ap-south-1.compute.internal", + "primary_network_interface_id": "eni-0fd429046b8c821e8", + "private_dns": "ip-172-31-38-63.ap-south-1.compute.internal", "private_dns_name_options": [ { "enable_resource_name_dns_a_record": false, @@ -101,9 +101,9 @@ "hostname_type": "ip-name" } ], - "private_ip": "172.31.42.89", - "public_dns": "ec2-13-235-133-84.ap-south-1.compute.amazonaws.com", - "public_ip": "13.235.133.84", + "private_ip": "172.31.38.63", + "public_dns": "ec2-13-127-41-61.ap-south-1.compute.amazonaws.com", + "public_ip": "13.127.41.61", "root_block_device": [ { "delete_on_termination": true, @@ -114,7 +114,7 @@ "tags": {}, "tags_all": {}, "throughput": 125, - "volume_id": "vol-042eda8621c87c905", + "volume_id": "vol-07bcc49968af98230", "volume_size": 8, "volume_type": "gp3" } @@ -134,12 +134,12 @@ }, "tenancy": "default", "timeouts": null, - "user_data": "e95276fef373e43ed1a86ae46edca2934abe2670", + "user_data": "ef4e1c30bf399ecc600bf0fff81d77451bc63c69", "user_data_base64": null, "user_data_replace_on_change": false, "volume_tags": null, "vpc_security_group_ids": [ - "sg-0f720301a65b23bc6" + "sg-0c493d9ce63a3a06f" ] }, "sensitive_attributes": [], @@ -165,7 +165,7 @@ "id": "key-tf", "key_name": "key-tf", "key_name_prefix": "", - "key_pair_id": "key-0ecd583addb722062", + "key_pair_id": "key-0146f9c0727309d71", "key_type": "rsa", "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4fWINmsr6W4Jot5PqdKljwA2x3iijFs/NB37ygV74ZoeAUnJ+plrlhuZ3hW9Hty/ZNlHcd6qC+h1q7m6pJR2FYqVdc9xikNx6eTH9I3ssos+5kgP447gpMrA3ap0DBqvt5YjwlcbVQuE3NZIAHUnHV9veil3JjALj/dbzAdXaG7P1vL3lxP72yavRizeeRPfrze2FqMvyDHmiDgo+URIo5DeJu2tJMuPUQ2zwcFWhhI7XolJHoU/CY3Hm9lJM8aGS6J81Hn9yRO1ztAerd7mcwIDUAFU3a6xsfPCDoBe6QA59nTlFSFChabnYH1DfP1Tl5mty+HyQV6kAPZSbzBpPVnhunpQyeEVE3cFkzxHzGM4jlW7WL45FuSHD8u2TVZVOgXJfflCkfXSqQssRRUYS+i5ylzkBhR+YZbhZZ0dOMA8i1OPfpWXT4LZ9Et2MEYnkapGYMnRfw/LDrMWwATB3DgbQle7LKU/wTD0767DrqLBEoUWnU8Q8pwLr/kh52fM= dev@dev-B85M-D3H", "tags": null, @@ -185,7 +185,7 @@ { "schema_version": 1, "attributes": { - "arn": "arn:aws:ec2:ap-south-1:454461993352:security-group/sg-0f720301a65b23bc6", + "arn": "arn:aws:ec2:ap-south-1:454461993352:security-group/sg-0c493d9ce63a3a06f", "description": "Allow HTTP and SSH inbound traffic", "egress": [ { @@ -204,7 +204,7 @@ "to_port": 0 } ], - "id": "sg-0f720301a65b23bc6", + "id": "sg-0c493d9ce63a3a06f", "ingress": [ { "cidr_blocks": [ diff --git a/AWS Automation/terraform.tfstate.backup b/AWS Automation/terraform.tfstate.backup index 583e8c2..1fee0ff 100644 --- a/AWS Automation/terraform.tfstate.backup +++ b/AWS Automation/terraform.tfstate.backup @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.8.5", - "serial": 63, + "serial": 101, "lineage": "c1e8351c-40a2-09a6-4b89-4bfb8790be4f", "outputs": {}, "resources": [], diff --git a/AWS Automation/test-folder/test.txt b/AWS Automation/test-folder/test.txt new file mode 100644 index 0000000..0611c7f --- /dev/null +++ b/AWS Automation/test-folder/test.txt @@ -0,0 +1 @@ +this is testing for folder copy \ No newline at end of file