Feature update backend (#3)
* Update Terraform backend configuration and add backend.conf sample --------- Co-authored-by: Damien A <sepales.pret0h@icloud.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -43,3 +43,4 @@ network_images/*.tar.xz
|
||||
.vscode/settings.json
|
||||
.vscode
|
||||
ansible/clab_vars.yml
|
||||
terraform/backend.conf
|
||||
|
||||
@@ -56,7 +56,7 @@ Before you begin, ensure you have the following prerequisites installed and conf
|
||||
|
||||
```bash
|
||||
cd terraform
|
||||
terraform init
|
||||
terraform init --backend-config="backend.conf"
|
||||
```
|
||||
|
||||
4. **Apply Terraform Configuration**
|
||||
|
||||
@@ -10,22 +10,27 @@ This directory contains the Terraform configuration files for deploying an AWS E
|
||||
|
||||
## Configuration
|
||||
|
||||
1. **Set AWS Credentials and Variables**
|
||||
1. **Backend Configuration**
|
||||
|
||||
Rename the `terraform.tfvars.sample` to `terraform.tfvars` and update the following variables with your own values:
|
||||
To easily manage the backend configuration, we will store the tfstate files on an S3 bucket.
|
||||
To update it, please adapt the `backend.conf` file, using the provided sample as a reference.
|
||||
|
||||
```tfvars
|
||||
AWS_ACCESS_KEY = "your_access_key"
|
||||
AWS_SECRET_KEY = "your_secret_key"
|
||||
AWS_KEY_NAME = "your_key_pair_name"
|
||||
AWS_KEY_LOCATION = "path_to_your_private_key"
|
||||
```
|
||||
2. **Set AWS Credentials and Variables**
|
||||
|
||||
Rename the `terraform.tfvars.sample` to `terraform.tfvars` and update the following variables with your own values:
|
||||
|
||||
```tfvars
|
||||
AWS_ACCESS_KEY = "your_access_key"
|
||||
AWS_SECRET_KEY = "your_secret_key"
|
||||
AWS_KEY_NAME = "your_key_pair_name"
|
||||
AWS_KEY_LOCATION = "path_to_your_private_key"
|
||||
```
|
||||
|
||||
**Important** : Never commit `terraform.tfvars` to version control as it contains sensitive information.
|
||||
|
||||
2. **Customize Terraform Variables**
|
||||
3. **Customize Terraform Variables**
|
||||
|
||||
You can customize the deployment by modifying the Terraform variables in `variables.tf`.
|
||||
You can customize the deployment by modifying the Terraform variables in `variables.tf`.
|
||||
|
||||
## Action made by the EC2.tf file
|
||||
|
||||
|
||||
3
terraform/backend.conf.sample
Normal file
3
terraform/backend.conf.sample
Normal file
@@ -0,0 +1,3 @@
|
||||
bucket = "YOUR_UNIQUE_BUCKET_NAME"
|
||||
key = "YOUR_OBJECT_KEY"
|
||||
region = "YOUR_REGION"
|
||||
@@ -1,9 +1,3 @@
|
||||
provider "aws" {
|
||||
region = var.AWS_REGION
|
||||
access_key = var.AWS_ACCESS_KEY
|
||||
secret_key = var.AWS_SECRET_KEY
|
||||
}
|
||||
|
||||
resource "aws_security_group" "netlab_sg" {
|
||||
name = "netlab_sg"
|
||||
|
||||
|
||||
9
terraform/provider.tf
Normal file
9
terraform/provider.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
provider "aws" {
|
||||
region = var.AWS_REGION
|
||||
access_key = var.AWS_ACCESS_KEY
|
||||
secret_key = var.AWS_SECRET_KEY
|
||||
}
|
||||
|
||||
terraform {
|
||||
backend "s3" {}
|
||||
}
|
||||
Reference in New Issue
Block a user