fix aws_backend wo kms

This commit is contained in:
Michael Jerger 2023-07-05 08:58:53 +02:00
parent 1c08952a86
commit 2fa5e94cb6
5 changed files with 25 additions and 7 deletions

View file

@ -29,7 +29,6 @@ class Aws(Validateable, CredentialMappingDefault):
if self.aws_as_backend: if self.aws_as_backend:
result += self.__validate_is_not_empty__("aws_bucket") result += self.__validate_is_not_empty__("aws_bucket")
result += self.__validate_is_not_empty__("aws_bucket_key") result += self.__validate_is_not_empty__("aws_bucket_key")
result += self.__validate_is_not_empty__("aws_bucket_kms_key_id")
result += self.__validate_is_not_empty__("aws_region") result += self.__validate_is_not_empty__("aws_region")
return result return result
@ -48,8 +47,19 @@ class Aws(Validateable, CredentialMappingDefault):
def resources_from_package(self) -> Set[str]: def resources_from_package(self) -> Set[str]:
result = {"provider_registry.tf", "aws_provider.tf", "aws_provider_vars.tf"} result = {"provider_registry.tf", "aws_provider.tf", "aws_provider_vars.tf"}
if self.aws_as_backend: if self.aws_as_backend:
if self.aws_bucket_kms_key_id:
result.update( result.update(
{"aws_backend_properties_vars.tf", "aws_backend_with_properties.tf"} {
"aws_backend_wkms_vars.tf",
"aws_backend.tf",
}
)
else:
result.update(
{
"aws_backend_wokms_vars.tf",
"aws_backend.tf",
}
) )
return result return result
@ -65,6 +75,11 @@ class Aws(Validateable, CredentialMappingDefault):
"account_name": self.aws_account_name, "account_name": self.aws_account_name,
"bucket": self.aws_bucket, "bucket": self.aws_bucket,
"key": self.__bucket_key__(), "key": self.__bucket_key__(),
}
)
if self.aws_bucket_kms_key_id:
result.update(
{
"kms_key_id": self.aws_bucket_kms_key_id, "kms_key_id": self.aws_bucket_kms_key_id,
} }
) )

View file

@ -0,0 +1,3 @@
variable "account_name" {}
variable "bucket" {}
variable "key" {}

View file

@ -161,10 +161,10 @@ def test_should_calculate_resources_from_package():
"provider_registry.tf", "provider_registry.tf",
"hetzner_provider.tf", "hetzner_provider.tf",
"hetzner_provider_vars.tf", "hetzner_provider_vars.tf",
"aws_backend_with_properties.tf", "aws_backend.tf",
"aws_provider.tf", "aws_provider.tf",
"aws_provider_vars.tf", "aws_provider_vars.tf",
"aws_backend_properties_vars.tf", "aws_backend_wkms_vars.tf",
"my.file", "my.file",
} == sut.resources_from_package() } == sut.resources_from_package()