Skip to content

Commit

Permalink
feat: update new github-action and subnet vpc tag
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Aug 2, 2023
1 parent 071d084 commit f1979bc
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 45 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/tf-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ on:
pull_request:
workflow_dispatch:
jobs:
complete:
example:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
working_directory: './_examples/complete/'
basic:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
working_directory: './_examples/basic/'
working_directory: './_example/'
20 changes: 7 additions & 13 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Run `make readme` to rebuild the `README.md`
#


# Name of this project
name: Terraform AWS Backup

Expand All @@ -16,20 +15,15 @@ github_repo: clouddrove/terraform-aws-backup

# Badges to display
badges:
- name: "Terraform"
image: "https://img.shields.io/badge/Terraform-v1.1.7-green"
url: "https://www.terraform.io"
- name: "Latest Release"
image: "https://img.shields.io/github/release/clouddrove/terraform-aws-backup.svg"
url: "https://github.com/clouddrove/terraform-aws-backup/releases/latest"
- name: "tfsec"
image: "https://github.com/clouddrove/terraform-aws-backup/actions/workflows/tfsec.yml/badge.svg"
url: "https://github.com/terraform-aws-backup/actions/workflows/tfsec.yml"
- name: "Licence"
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
url: "LICENSE.md"
- name: "tfsec"
image: "https://github.com/terraform-aws-backup/actions/workflows/tfsec.yml/badge.svg"
url: "https://github.com/terraform-aws-backup/actions/workflows/tfsec.yml"
- name: "static-checks"
image: "https://github.com/terraform-aws-backup/actions/workflows/terraform.yml/badge.svg"
url: "https://github.com/terraform-aws-backup/actions/workflows/terraform.yml"



# description of this project
description: |-
Expand All @@ -40,7 +34,7 @@ include:
- "terraform.md"

# How to use this project
# yamllint disable rule:line-length
# How to use this project
usage: |-
### Simple Example
Here is an example of how you can use this module in your inventory structure:
Expand Down
6 changes: 3 additions & 3 deletions _example/versions.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.4.6"
required_version = ">= 1.5.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.1.0"
version = ">= 5.9.0"
}
}
}
}
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resource "aws_backup_plan" "default" {

rule {
rule_name = module.labels.id
target_vault_name = var.target_vault_name == null ? join("", aws_backup_vault.default.*.name) : var.target_vault_name
target_vault_name = var.target_vault_name == null ? join("", aws_backup_vault.default[*].name) : var.target_vault_name
schedule = var.schedule
start_window = var.start_window
completion_window = var.completion_window
Expand Down Expand Up @@ -87,22 +87,22 @@ data "aws_iam_policy_document" "assume_role" {
"backup:PutBackupVaultNotifications",
]

resources = [join("", aws_backup_vault.default.*.arn)]
resources = [join("", aws_backup_vault.default[*].arn)]
}
}

resource "aws_backup_vault_policy" "example" {
count = var.aws_backup_vault_policy_enabled ? 1 : 0

backup_vault_name = join("", aws_backup_vault.default.*.name)
policy = element(data.aws_iam_policy_document.assume_role.*.json, count.index)
backup_vault_name = join("", aws_backup_vault.default[*].name)
policy = element(data.aws_iam_policy_document.assume_role[*].json, count.index)
}

resource "aws_iam_role" "default" {
count = local.iam_role_enabled && var.aws_backup_vault_policy_enabled == false ? 1 : 0

name = var.target_iam_role_name == null ? module.labels.id : var.target_iam_role_name
assume_role_policy = element(data.aws_iam_policy_document.assume_role.*.json, count.index)
assume_role_policy = element(data.aws_iam_policy_document.assume_role[*].json, count.index)
tags = module.labels.tags
}

Expand All @@ -115,14 +115,14 @@ data "aws_iam_role" "existing" {
resource "aws_iam_role_policy_attachment" "default" {
count = local.iam_role_enabled && var.aws_backup_vault_policy_enabled == false ? 1 : 0
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup"
role = join("", aws_iam_role.default.*.name)
role = join("", aws_iam_role.default[*].name)
}

resource "aws_backup_selection" "default" {
count = local.plan_enabled && var.aws_backup_vault_policy_enabled == false ? 1 : 0
name = module.labels.id
iam_role_arn = join("", var.iam_role_enabled ? aws_iam_role.default.*.arn : data.aws_iam_role.existing.*.arn)
plan_id = join("", aws_backup_plan.default.*.id)
iam_role_arn = join("", var.iam_role_enabled ? aws_iam_role.default[*].arn : data.aws_iam_role.existing[*].arn)
plan_id = join("", aws_backup_plan.default[*].id)
resources = var.backup_resources
dynamic "selection_tag" {
for_each = var.selection_tags
Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
output "id" {
value = join("", aws_backup_plan.default.*.id)
value = join("", aws_backup_plan.default[*].id)
description = "A mapping of tags to assign to the key."

}

output "arn" {
value = join("", aws_backup_plan.default.*.arn)
value = join("", aws_backup_plan.default[*].arn)
description = "A mapping of tags to assign to the certificate."
}

Expand All @@ -14,6 +14,6 @@ output "tags" {
description = "A mapping of tags to assign to the resource."
}
output "backup_id" {
value = join("", aws_backup_selection.default.*.id)
value = join("", aws_backup_selection.default[*].id)
description = "Backup Selection identifier."
}
12 changes: 0 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ variable "label_order" {
description = "Label order, e.g. `name`,`application`."
}

variable "attributes" {
type = list(any)
default = []
description = "Additional attributes (e.g. `1`)."
}

variable "delimiter" {
type = string
default = "-"
description = "Delimiter to be used between `organization`, `environment`, `name` and `attributes`."
}

variable "managedby" {
type = string
default = "hello@clouddrove.com"
Expand Down
11 changes: 11 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.9.0"
}
}
}

0 comments on commit f1979bc

Please sign in to comment.