Skip to content

Commit

Permalink
Add script for generating payload
Browse files Browse the repository at this point in the history
  • Loading branch information
anusha94 committed Apr 12, 2024
1 parent 6f570a9 commit 911744b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 26 deletions.
52 changes: 26 additions & 26 deletions config-files/terraform/ecs/payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
],
"tags": null,
"update_default_version": null,
"user_data": "IyEvYmluL2Jhc2gKZWNobyBFQ1NfQ0xVU1RFUj1teS1lY3MtY2x1c3RlciA+PiAvZXRjL2Vjcy9lY3MuY29uZmln"
"user_data": "IyEvYmluL2Jhc2gKZWNobyBFQ1NfQ0xVU1RFUj1teS1lY3MtY2x1c3RlciA+PiAvZXRjL2Vjcy9lY3MuY29uZmlnCg=="
},
"sensitive_values": {
"block_device_mappings": [
Expand Down Expand Up @@ -1279,7 +1279,7 @@
],
"tags": null,
"update_default_version": null,
"user_data": "IyEvYmluL2Jhc2gKZWNobyBFQ1NfQ0xVU1RFUj1teS1lY3MtY2x1c3RlciA+PiAvZXRjL2Vjcy9lY3MuY29uZmln"
"user_data": "IyEvYmluL2Jhc2gKZWNobyBFQ1NfQ0xVU1RFUj1teS1lY3MtY2x1c3RlciA+PiAvZXRjL2Vjcy9lY3MuY29uZmlnCg=="
},
"after_unknown": {
"arn": true,
Expand Down Expand Up @@ -2600,87 +2600,87 @@
},
"relevant_attributes": [
{
"resource": "aws_vpc.main",
"resource": "aws_internet_gateway.internet_gateway",
"attribute": [
"id"
]
},
{
"resource": "aws_vpc.main",
"resource": "aws_route_table.route_table",
"attribute": [
"cidr_block"
"id"
]
},
{
"resource": "aws_subnet.subnet",
"resource": "aws_lb_target_group.ecs_tg",
"attribute": [
"id"
"arn"
]
},
{
"resource": "aws_subnet.subnet2",
"resource": "aws_ecs_cluster.ecs_cluster",
"attribute": [
"id"
"name"
]
},
{
"resource": "aws_launch_template.ecs_lt",
"resource": "aws_vpc.main",
"attribute": [
"id"
]
},
{
"resource": "aws_autoscaling_group.ecs_asg",
"resource": "aws_vpc.main",
"attribute": [
"arn"
"cidr_block"
]
},
{
"resource": "aws_route_table.route_table",
"resource": "aws_lb.ecs_alb",
"attribute": [
"id"
"arn"
]
},
{
"resource": "aws_lb.ecs_alb",
"resource": "aws_subnet.subnet",
"attribute": [
"arn"
"id"
]
},
{
"resource": "aws_internet_gateway.internet_gateway",
"resource": "aws_security_group.security_group",
"attribute": [
"id"
]
},
{
"resource": "aws_security_group.security_group",
"resource": "aws_launch_template.ecs_lt",
"attribute": [
"id"
]
},
{
"resource": "aws_lb_target_group.ecs_tg",
"resource": "aws_ecs_task_definition.ecs_task_definition",
"attribute": [
"arn"
]
},
{
"resource": "aws_ecs_capacity_provider.ecs_capacity_provider",
"resource": "aws_subnet.subnet2",
"attribute": [
"name"
"id"
]
},
{
"resource": "aws_ecs_cluster.ecs_cluster",
"resource": "aws_autoscaling_group.ecs_asg",
"attribute": [
"name"
"arn"
]
},
{
"resource": "aws_ecs_task_definition.ecs_task_definition",
"resource": "aws_ecs_capacity_provider.ecs_capacity_provider",
"attribute": [
"arn"
"name"
]
},
{
Expand All @@ -2690,5 +2690,5 @@
]
}
],
"timestamp": "2024-04-11T09:01:44Z"
"timestamp": "2024-04-12T08:24:55Z"
}
35 changes: 35 additions & 0 deletions scripts/install-tf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Function to install Terraform
install_terraform() {
echo "Installing Terraform..."
# Download Terraform binary
wget https://releases.hashicorp.com/terraform/0.15.0/terraform_0.15.0_linux_amd64.zip
# Unzip the downloaded file
unzip terraform_0.15.0_linux_amd64.zip
# Move Terraform binary to /usr/local/bin
sudo mv terraform /usr/local/bin/
echo "Terraform installed successfully."
}

# Function to run Terraform commands
run_terraform_commands() {
echo "Running Terraform commands..."
# Initialize Terraform in the directory where your configuration files are located
terraform init
# Plan the changes Terraform will make
terraform plan -out tfplan.binary
# Store in JSON
terraform show -json tfplan.binary | jq > payload.json
echo "Terraform commands executed successfully."
}

# Check if Terraform is already installed
if command -v terraform &> /dev/null; then
echo "Terraform is already installed."
run_terraform_commands
else
install_terraform
run_terraform_commands
fi

0 comments on commit 911744b

Please sign in to comment.