provider/aws: data_source_aws_iam_server_certificate latest should be (#11016)
bool not string Fixes: #11010 Adds a test to show cover the use-case that the OP suggested caused the panic ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSDataSourceIAMServerCertificate_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/01/03 22:39:21 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSDataSourceIAMServerCertificate_ -timeout 120m === RUN TestAccAWSDataSourceIAMServerCertificate_basic --- PASS: TestAccAWSDataSourceIAMServerCertificate_basic (19.48s) === RUN TestAccAWSDataSourceIAMServerCertificate_matchNamePrefix --- PASS: TestAccAWSDataSourceIAMServerCertificate_matchNamePrefix (1.95s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 21.454s ```
This commit is contained in:
parent
cb993a49f6
commit
56c352a535
|
@ -16,7 +16,7 @@ func dataSourceAwsIAMServerCertificate() *schema.Resource {
|
||||||
Read: dataSourceAwsIAMServerCertificateRead,
|
Read: dataSourceAwsIAMServerCertificateRead,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
@ -32,7 +32,7 @@ func dataSourceAwsIAMServerCertificate() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"name_prefix": &schema.Schema{
|
"name_prefix": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
@ -46,24 +46,24 @@ func dataSourceAwsIAMServerCertificate() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"latest": &schema.Schema{
|
"latest": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Default: false,
|
Default: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
"arn": &schema.Schema{
|
"arn": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"path": &schema.Schema{
|
"path": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"expiration_date": &schema.Schema{
|
"expiration_date": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,7 @@ package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -55,9 +56,30 @@ func TestAccAWSDataSourceIAMServerCertificate_basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccAWSDataSourceIAMServerCertificate_matchNamePrefix(t *testing.T) {
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckIAMServerCertificateDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccAwsDataIAMServerCertConfigMatchNamePrefix,
|
||||||
|
ExpectError: regexp.MustCompile(`Search for AWS IAM server certificate returned no results`),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var testAccAwsDataIAMServerCertConfig = fmt.Sprintf(`%s
|
var testAccAwsDataIAMServerCertConfig = fmt.Sprintf(`%s
|
||||||
data "aws_iam_server_certificate" "test" {
|
data "aws_iam_server_certificate" "test" {
|
||||||
name = "${aws_iam_server_certificate.test_cert.name}"
|
name = "${aws_iam_server_certificate.test_cert.name}"
|
||||||
latest = true
|
latest = true
|
||||||
}
|
}
|
||||||
`, testAccIAMServerCertConfig)
|
`, testAccIAMServerCertConfig)
|
||||||
|
|
||||||
|
var testAccAwsDataIAMServerCertConfigMatchNamePrefix = `
|
||||||
|
data "aws_iam_server_certificate" "test" {
|
||||||
|
name_prefix = "MyCert"
|
||||||
|
latest = true
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
Loading…
Reference in New Issue