diff --git a/project_setup/scripts/terraform-to-secrets b/project_setup/scripts/terraform-to-secrets index 00c8fbc..7bf3eba 100755 --- a/project_setup/scripts/terraform-to-secrets +++ b/project_setup/scripts/terraform-to-secrets @@ -129,7 +129,13 @@ def parse_tagged_resources( ) -> Generator[Tuple[str, str], None, None]: """Search all resources for tags requesting the creation of a secret.""" for resource in find_resources(terraform_state, None): - tags: Dict[str, str] = resource["values"].get("tags", dict()) + # Ensure "tags" key exists in resource["values"] and if it does, + # make sure its value is not None. Both of these cases can occur. + tags: Dict[str, str] + if "tags" not in resource["values"] or resource["values"].get("tags") is None: + tags = dict() + else: + tags = resource["values"]["tags"] secret_name: Optional[str] = tags.get(GITHUB_SECRET_NAME_TAG) lookup_tag: Optional[str] = tags.get(GITHUB_SECRET_TERRAFORM_LOOKUP_TAG) secret_value: str