Skip to content

Commit

Permalink
Merge pull request #28620 from bennylu2/b-aws_apprunner_service-27733
Browse files Browse the repository at this point in the history
aws_apprunner_service observability_configuration_arn optional
  • Loading branch information
ewbankkit authored Jan 10, 2023
2 parents 2a12f86 + 183aff9 commit 86bf014
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/28620.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_apprunner_service: `observability_configuration_arn` is optional
```
4 changes: 2 additions & 2 deletions internal/service/apprunner/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func ResourceService() *schema.Resource {
Schema: map[string]*schema.Schema{
"observability_configuration_arn": {
Type: schema.TypeString,
Required: true,
Optional: true,
ValidateFunc: verify.ValidARN,
},
"observability_enabled": {
Expand Down Expand Up @@ -790,7 +790,7 @@ func expandServiceObservabilityConfiguration(l []interface{}) *apprunner.Service

result := &apprunner.ServiceObservabilityConfiguration{}

if v, ok := tfMap["observability_configuration_arn"].(string); ok {
if v, ok := tfMap["observability_configuration_arn"].(string); ok && len(v) > 0 {
result.ObservabilityConfigurationArn = aws.String(v)
}

Expand Down
37 changes: 37 additions & 0 deletions internal/service/apprunner/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ func TestAccAppRunnerService_ImageRepository_networkConfiguration(t *testing.T)

func TestAccAppRunnerService_ImageRepository_observabilityConfiguration(t *testing.T) {
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rName2 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_apprunner_service.test"
observabilityConfigurationResourceName := "aws_apprunner_observability_configuration.test"

Expand All @@ -334,6 +335,14 @@ func TestAccAppRunnerService_ImageRepository_observabilityConfiguration(t *testi
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccServiceConfig_ImageRepository_observabilityConfiguration_disabled(rName2),
Check: resource.ComposeTestCheckFunc(
testAccCheckServiceExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "observability_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "observability_configuration.0.observability_enabled", "false"),
),
},
},
})
}
Expand Down Expand Up @@ -736,6 +745,34 @@ resource "aws_apprunner_observability_configuration" "test" {
`, rName)
}

func testAccServiceConfig_ImageRepository_observabilityConfiguration_disabled(rName string) string {
return fmt.Sprintf(`
resource "aws_apprunner_service" "test" {
service_name = %[1]q
health_check_configuration {
healthy_threshold = 2
timeout = 5
}
observability_configuration {
observability_enabled = false
}
source_configuration {
auto_deployments_enabled = false
image_repository {
image_configuration {
port = "80"
}
image_identifier = "public.ecr.aws/nginx/nginx:latest"
image_repository_type = "ECR_PUBLIC"
}
}
}
`, rName)
}

func testAccIAMRole(rName string) string {
return fmt.Sprintf(`
data "aws_partition" "current" {}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/apprunner_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ The `egress_configuration` block supports the following argument:

The `observability_configuration` block supports the following arguments:

* `observability_configuration_arn` - (Required) ARN of the observability configuration that is associated with the service.
* `observability_enabled` - (Required) When `true`, an observability configuration resource is associated with the service.
* `observability_configuration_arn` - (Optional) ARN of the observability configuration that is associated with the service. Specified only when `observability_enabled` is `true`.

### Code Repository

Expand Down

0 comments on commit 86bf014

Please sign in to comment.