Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_apprunner_service observability_configuration_arn optional #28620

Merged
merged 3 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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