Skip to content

Commit 0abe7df

Browse files
committed
fix: resolved the kubecost role
1 parent 23149b9 commit 0abe7df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kubecosts.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ locals {
1818

1919
## IAM Bucket Policy for the Kubecost Federated Bucket
2020
data "aws_iam_policy_document" "kubecost_federated_bucket_policy" {
21+
count = local.enable_kubecosts ? 1 : 0
22+
2123
statement {
2224
effect = "Allow"
2325
actions = ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"]
2426
principals {
2527
type = "AWS"
2628
identifiers = concat(
2729
[local.root_account_arn],
28-
[module.kubecost_pod_identity[0].iam_role_arn],
30+
[try(module.kubecost_pod_identity[0].iam_role_arn, null)],
2931
)
3032
}
3133
resources = [
@@ -80,7 +82,7 @@ module "kubecost_federated_bucket" {
8082
attach_require_latest_tls_policy = true
8183
force_destroy = true
8284
object_ownership = "BucketOwnerEnforced"
83-
policy = data.aws_iam_policy_document.kubecost_federated_bucket_policy.json
85+
policy = data.aws_iam_policy_document.kubecost_federated_bucket_policy[0].json
8486
tags = local.tags
8587

8688
lifecycle_rule = [

0 commit comments

Comments
 (0)