File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -56,19 +56,21 @@ data "aws_iam_policy_document" "default" {
5656}
5757
5858data "aws_s3_bucket" "logs_bucket" {
59+ count = var. session_logging_enabled ? 1 : 0
5960 bucket = try (coalesce (var. session_logging_bucket_name , module. logs_bucket . bucket_id ), " " )
6061}
6162
6263# https://docs.aws.amazon.com/systems-manager/latest/userguide/getting-started-create-iam-instance-profile.html#create-iam-instance-profile-ssn-logging
6364data "aws_iam_policy_document" "session_logging" {
65+ count = var. session_logging_enabled ? 1 : 0
6466
6567 statement {
6668 sid = " SSMAgentSessionAllowS3Logging"
6769 effect = " Allow"
6870 actions = [
6971 " s3:PutObject"
7072 ]
71- resources = [" ${ data . aws_s3_bucket . logs_bucket . arn } /*" ]
73+ resources = [" ${ join ( " " , data. aws_s3_bucket . logs_bucket . * . arn ) } /*" ]
7274 }
7375
7476 statement {
@@ -119,7 +121,7 @@ resource "aws_iam_role_policy" "session_logging" {
119121
120122 name = " ${ module . role_label . id } -session-logging"
121123 role = aws_iam_role. default . name
122- policy = data. aws_iam_policy_document . session_logging . json
124+ policy = join ( " " , data. aws_iam_policy_document . session_logging . * . json )
123125}
124126
125127resource "aws_iam_instance_profile" "default" {
Original file line number Diff line number Diff line change @@ -24,11 +24,11 @@ output "role_id" {
2424}
2525
2626output "session_logging_bucket_id" {
27- value = var. session_logging_enabled && var. session_logging_bucket_name == " " ? data. aws_s3_bucket . logs_bucket . id : " "
27+ value = var. session_logging_enabled && var. session_logging_bucket_name == " " ? join ( " " , data. aws_s3_bucket . logs_bucket . * . id ) : " "
2828 description = " The ID of the SSM Agent Session Logging S3 Bucket."
2929}
3030
3131output "session_logging_bucket_arn" {
32- value = var. session_logging_enabled && var. session_logging_bucket_name == " " ? data. aws_s3_bucket . logs_bucket . arn : " "
32+ value = var. session_logging_enabled && var. session_logging_bucket_name == " " ? join ( " " , data. aws_s3_bucket . logs_bucket . * . arn ) : " "
3333 description = " The ARN of the SSM Agent Session Logging S3 Bucket."
3434}
You can’t perform that action at this time.
0 commit comments