Skip to content

Commit

Permalink
aws_secret_backend: credentials are optional
Browse files Browse the repository at this point in the history
  • Loading branch information
adongy committed Dec 13, 2019
1 parent bd8d994 commit 5837bf2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vault/resource_aws_secret_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func awsSecretBackendResource() *schema.Resource {
},
"access_key": {
Type: schema.TypeString,
Required: true,
Optional: true,
Description: "The AWS Access Key ID to use when generating new credentials.",
Sensitive: true,
},
"secret_key": {
Type: schema.TypeString,
Required: true,
Optional: true,
Description: "The AWS Secret Access Key to use when generating new credentials.",
Sensitive: true,
},
Expand Down
23 changes: 23 additions & 0 deletions vault/resource_aws_secret_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ func TestAccAWSSecretBackend_basic(t *testing.T) {
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "region", "us-west-1"),
),
},
{
Config: testAccAWSSecretBackendConfig_noCreds(path),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "path", path),
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "description", "test description"),
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "default_lease_ttl_seconds", "1800"),
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "max_lease_ttl_seconds", "43200"),
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "access_key", ""),
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "secret_key", ""),
resource.TestCheckResourceAttr("vault_aws_secret_backend.test", "region", "us-west-1"),
),
},
},
})
}
Expand Down Expand Up @@ -125,3 +137,14 @@ resource "vault_aws_secret_backend" "test" {
region = "us-west-1"
}`, path, accessKey, secretKey)
}

func testAccAWSSecretBackendConfig_noCreds(path string) string {
return fmt.Sprintf(`
resource "vault_aws_secret_backend" "test" {
path = "%s"
description = "test description"
default_lease_ttl_seconds = 1800
max_lease_ttl_seconds = 43200
region = "us-west-1"
}`, path)
}

0 comments on commit 5837bf2

Please sign in to comment.