File tree Expand file tree Collapse file tree 6 files changed +51
-38
lines changed
Expand file tree Collapse file tree 6 files changed +51
-38
lines changed Original file line number Diff line number Diff line change 1- ## Requirements
1+ # AWS Backup Vault Terraform Configuration
22
3- | Name | Version |
4- | ------| ---------|
5- | <a name =" requirement_aws " ></a > [ aws] ( #requirement\_ aws ) | >= 4.0 |
3+ To create or update the AWS config, Terraform must be run from a local machine, as there is currently no GitHub Action set up for this.
64
7- ## Providers
5+ The following commands should be used as a suggestion for the process:
86
9- | Name | Version |
10- | ------| ---------|
11- | <a name =" provider_aws " ></a > [ aws] ( #provider\_ aws ) | >= 4.0 |
7+ ``` shell
8+ aws sso login --sso-session PRM
129
13- ## Modules
10+ export AWS_PROFILE=NDR-Pre-Prod-Backup-RW
11+ terraform init -backend-config=pre-prod.s3.tfbackend -upgrade -reconfigure
12+ terraform workspace list
13+ terraform workspace select pre-prod
14+ terraform plan
15+ terraform apply
1416
15- No modules.
16-
17- ## Resources
18-
19- | Name | Type |
20- | ------| ------|
21- | [ aws_backup_vault.backup_vault] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault ) | resource |
22- | [ aws_backup_vault_policy.backup_policy] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault_policy ) | resource |
23- | [ aws_kms_alias.encryption_key_alias] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias ) | resource |
24- | [ aws_kms_key.encryption_key] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key ) | resource |
25- | [ aws_ssm_parameter.backup-source-account] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter ) | data source |
26-
27- ## Inputs
28-
29- No inputs.
30-
31- ## Outputs
32-
33- No outputs.
17+ export AWS_PROFILE=NDR-Prod-Backup-RW
18+ terraform init -backend-config=prod.s3.tfbackend -upgrade -reconfigure
19+ terraform workspace list
20+ terraform workspace select prod-backup
21+ terraform plan
22+ terraform apply
23+ ` ` `
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ resource "aws_kms_alias" "encryption_key_alias" {
1212 target_key_id = aws_kms_key. encryption_key . id
1313}
1414
15-
1615resource "aws_backup_vault_policy" "backup_policy" {
1716 backup_vault_name = aws_backup_vault. backup_vault . name
1817
@@ -21,10 +20,10 @@ resource "aws_backup_vault_policy" "backup_policy" {
2120 " Version" : " 2012-10-17" ,
2221 " Statement" : [
2322 {
24- " Sid" : " Allow ${ data . aws_ssm_parameter . backup-source-account . value } to copy into pre-prod_backup_vault" ,
23+ " Sid" : " Allow ${ data . aws_ssm_parameter . backup_source_account . value } to copy into pre-prod_backup_vault" ,
2524 " Effect" : " Allow" ,
2625 " Principal" : {
27- " AWS" : " arn:aws:iam::${ data . aws_ssm_parameter . backup-source-account . value } :root"
26+ " AWS" : " arn:aws:iam::${ data . aws_ssm_parameter . backup_source_account . value } :root"
2827 },
2928 " Action" : " backup:CopyIntoBackupVault" ,
3029 " Resource" : " *"
@@ -34,7 +33,6 @@ resource "aws_backup_vault_policy" "backup_policy" {
3433 )
3534}
3635
37- data "aws_ssm_parameter" "backup-source-account " {
36+ data "aws_ssm_parameter" "backup_source_account " {
3837 name = " backup-source-account"
3938}
40-
Original file line number Diff line number Diff line change 1+ resource "aws_iam_policy" "administrator_permission_restrictions" {
2+ name = " AdministratorRestriction"
3+ policy = jsonencode ({
4+ Version = " 2012-10-17" ,
5+ Statement = [
6+ {
7+ Effect = " Deny" ,
8+ Action = [
9+ " s3:DeleteObject" ,
10+ " s3:DeleteObjectVersion" ,
11+ " s3:PutLifecycleConfiguration" ,
12+ " s3:PutObject" ,
13+ " s3:RestoreObject"
14+ ],
15+ Resource = [
16+ " arn:aws:s3:::*/*.tfstate"
17+ ]
18+ }
19+ ]
20+ })
21+ tags = {
22+ Name = " AdministratorRestriction"
23+ Workspace = " core"
24+ }
25+ }
Original file line number Diff line number Diff line change @@ -2,16 +2,18 @@ terraform {
22 required_providers {
33 aws = {
44 source = " hashicorp/aws"
5- version = " >= 4 .0"
5+ version = " ~> 6 .0"
66 }
77 }
8+
89 backend "s3" {
910 use_lockfile = true
1011 region = " eu-west-2"
1112 key = " ndr/terraform.tfstate"
1213 encrypt = true
1314 }
1415}
16+
1517provider "aws" {
1618 region = " eu-west-2"
1719}
Original file line number Diff line number Diff line change 11bucket = "ndr-backup-terraform-state"
2- dynamodb_table = "ndr-backup-terraform-lock"
32region = "eu-west-2"
43key = "backup/terraform.tfstate"
54encrypt = true
Original file line number Diff line number Diff line change 1- bucket = "ndr-backup-terraform-state"
2- dynamodb_table = "ndr-backup-terraform-lock"
1+ bucket = "ndr-prod-backup-terraform-state"
32region = "eu-west-2"
4- key = "backup /terraform.tfstate"
3+ key = "ndr /terraform.tfstate"
54encrypt = true
You can’t perform that action at this time.
0 commit comments