Skip to content

Commit

Permalink
fix: Ensure karpenter and velero resources are not created when t…
Browse files Browse the repository at this point in the history
…hey are not enabled (#149)

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
  • Loading branch information
gohmc and bryantbiggs committed May 1, 2023
1 parent 934a1ea commit e8c244d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.3
rev: v1.78.0
hooks:
- id: terraform_fmt
- id: terraform_docs
Expand Down
11 changes: 6 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,8 @@ locals {
}

data "aws_iam_role" "karpenter" {
name = var.karpenter_instance_profile.iam_role_name
count = var.enable_karpenter ? 1 : 0
name = var.karpenter_instance_profile.iam_role_name
}

data "aws_iam_policy_document" "karpenter" {
Expand Down Expand Up @@ -2294,7 +2295,7 @@ data "aws_iam_policy_document" "karpenter" {

statement {
actions = ["iam:PassRole"]
resources = [data.aws_iam_role.karpenter.arn]
resources = [data.aws_iam_role.karpenter[0].arn]
}

statement {
Expand Down Expand Up @@ -2744,9 +2745,9 @@ module "secrets_store_csi_driver_provider_aws" {
locals {
velero_name = "velero"
velero_service_account = try(var.velero.service_account_name, "${local.velero_name}-server")
velero_backup_s3_bucket = split(":", var.velero.s3_backup_location)
velero_backup_s3_bucket_arn = try(split("/", var.velero.s3_backup_location)[0], var.velero.s3_backup_location)
velero_backup_s3_bucket_name = try(split("/", local.velero_backup_s3_bucket[5])[0], local.velero_backup_s3_bucket[5])
velero_backup_s3_bucket = try(split(":", var.velero.s3_backup_location), [])
velero_backup_s3_bucket_arn = try(split("/", var.velero.s3_backup_location)[0], var.velero.s3_backup_location, "")
velero_backup_s3_bucket_name = try(split("/", local.velero_backup_s3_bucket[5])[0], local.velero_backup_s3_bucket[5], "")
velero_backup_s3_bucket_prefix = try(split("/", var.velero.s3_backup_location)[1], "")
}

Expand Down

0 comments on commit e8c244d

Please sign in to comment.