Skip to content

Commit

Permalink
Fix schema set errors
Browse files Browse the repository at this point in the history
  • Loading branch information
appilon committed Jul 14, 2020
1 parent 8881e63 commit c2eedeb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 33 deletions.
21 changes: 0 additions & 21 deletions aws/data_source_aws_lambda_invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package aws

import (
"crypto/md5"
"encoding/json"
"fmt"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/lambda"
Expand Down Expand Up @@ -38,15 +36,6 @@ func dataSourceAwsLambdaInvocation() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"result_map": {
Type: schema.TypeMap,
Computed: true,
Deprecated: "use `result` attribute with jsondecode() function",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
}
Expand Down Expand Up @@ -77,16 +66,6 @@ func dataSourceAwsLambdaInvocationRead(d *schema.ResourceData, meta interface{})
return err
}

var result map[string]interface{}

if err = json.Unmarshal(res.Payload, &result); err != nil {
return err
}

if err = d.Set("result_map", result); err != nil {
log.Printf("[WARN] Cannot use the result invocation as a string map: %s", err)
}

d.SetId(fmt.Sprintf("%s_%s_%x", functionName, qualifier, md5.Sum(input)))

return nil
Expand Down
10 changes: 1 addition & 9 deletions aws/data_source_aws_lambda_invocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ func TestAccDataSourceAwsLambdaInvocation_basic(t *testing.T) {
{
Config: testAccDataSourceAwsLambdaInvocation_basic_config(rName, testData),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.%", "3"),
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.key1", "value1"),
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.key2", "value2"),
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.key3", testData),
testAccCheckLambdaInvocationResult("data.aws_lambda_invocation.invocation_test", `{"key1":"value1","key2":"value2","key3":"`+testData+`"}`),
),
},
Expand All @@ -67,10 +63,7 @@ func TestAccDataSourceAwsLambdaInvocation_qualifier(t *testing.T) {
{
Config: testAccDataSourceAwsLambdaInvocation_qualifier_config(rName, testData),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.%", "3"),
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.key1", "value1"),
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.key2", "value2"),
resource.TestCheckResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map.key3", testData),
testAccCheckLambdaInvocationResult("data.aws_lambda_invocation.invocation_test", `{"key1":"value1","key2":"value2","key3":"`+testData+`"}`),
),
},
},
Expand All @@ -88,7 +81,6 @@ func TestAccDataSourceAwsLambdaInvocation_complex(t *testing.T) {
{
Config: testAccDataSourceAwsLambdaInvocation_complex_config(rName, testData),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckNoResourceAttr("data.aws_lambda_invocation.invocation_test", "result_map"),
testAccCheckLambdaInvocationResult("data.aws_lambda_invocation.invocation_test", `{"key1":{"subkey1":"subvalue1"},"key2":{"subkey2":"subvalue2","subkey3":{"a": "b"}},"key3":"`+testData+`"}`),
),
},
Expand Down
5 changes: 5 additions & 0 deletions aws/data_source_aws_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func dataSourceAwsLb() *schema.Resource {
Computed: true,
},

"enable_http2": {
Type: schema.TypeBool,
Computed: true,
},

"idle_timeout": {
Type: schema.TypeInt,
Computed: true,
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_api_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func resourceAwsApiGatewayResource() *schema.Resource {
}
restApiID := idParts[0]
resourceID := idParts[1]
d.Set("request_validator_id", resourceID)
d.Set("rest_api_id", restApiID)
d.SetId(resourceID)
return []*schema.ResourceData{d}, nil
Expand Down
10 changes: 8 additions & 2 deletions aws/resource_aws_elasticsearch_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,14 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}
// because DescribeElasticsearchDomainConfig does not return MasterUserOptions
if ds.AdvancedSecurityOptions != nil {
if _, ok := d.GetOk("advanced_security_options"); ok {
d.Set("advanced_security_options.0.enabled", ds.AdvancedSecurityOptions.Enabled)
d.Set("advanced_security_options.0.internal_user_database_enabled", ds.AdvancedSecurityOptions.InternalUserDatabaseEnabled)
if err := d.Set("advanced_security_options", []interface{}{
map[string]interface{}{
"enabled": ds.AdvancedSecurityOptions.Enabled,
"internal_user_database_enabled": ds.AdvancedSecurityOptions.InternalUserDatabaseEnabled,
},
}); err != nil {
return fmt.Errorf("error setting advanced_security_options: %w", err)
}
} else {
if err := d.Set("advanced_security_options", flattenAdvancedSecurityOptions(ds.AdvancedSecurityOptions)); err != nil {
return fmt.Errorf("error setting advanced_security_options: %w", err)
Expand Down

0 comments on commit c2eedeb

Please sign in to comment.