Skip to content

Commit

Permalink
fix file detection
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Feb 24, 2021
1 parent 53d74d6 commit 7beb790
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions iam-saml/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ locals {
account_id = var.account_id != "" ? var.account_id : data.aws_caller_identity.current.account_id
account_environment = data.aws_arn.current.partition == "aws-us-gov" ? "gov" : "ew"

saml_ew_url = "https://signin.aws.amazon.com/saml"
saml_gov_url = "https://signin.amazonaws-us-gov.com/saml"
saml_url = local.account_environment == "gov" ? local.saml_gov_url : local.saml_ew_url
saml_ew_url = "https://signin.aws.amazon.com/saml"
saml_gov_url = "https://signin.amazonaws-us-gov.com/saml"
saml_url = local.account_environment == "gov" ? local.saml_gov_url : local.saml_ew_url
saml_metadata_file = file("${path.root}/setup/metadata.xml")
saml_metadata_file_exists = fileexists(local.saml_metadata_file)

base_tags = {
"boc:tf_module_version" = local._module_version
Expand All @@ -61,8 +63,9 @@ resource "null_resource" "saml_metadata" {
}

resource "aws_iam_saml_provider" "saml" {
count = local.saml_metadata_file_exists ? 1 : 0
name = var.saml_provider_name
saml_metadata_document = file("${path.root}/setup/metadata.xml")
saml_metadata_document = local.saml_metadata_file_exists ? local.saml_metadata_file : ""
depends_on = [null_resource.saml_metadata]

# when the provider supports tags, enable this section
Expand Down
2 changes: 1 addition & 1 deletion iam-saml/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

output "saml_provider" {
description = "SAML Provider ARN"
value = aws_iam_saml_provider.saml.arn
value = aws_iam_saml_provider.saml[0].arn
}

output "saml_assume_policy" {
Expand Down

0 comments on commit 7beb790

Please sign in to comment.