-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Readiness Checklist
- I am running the latest version
- I checked the documentation and found no answer
- I checked to make sure that this issue has not already been filed
- I am reporting the issue to the correct repository (for multi-repository projects)
Expected Behavior
After successfully applying an ec_security_project resource, all attributes should have known values in the Terraform state. The admin_features_package and product_types attributes should be populated with their values from the API response.
Current Behavior
After running terraform apply on an ec_security_project resource, the provider returns an error indicating that admin_features_package and product_types are still unknown values:
ec_security_project.test: Still creating... [1m20s elapsed]
╷
│ Error: Provider returned invalid result object after apply
│
│ After the apply operation, the provider still indicated an unknown value for ec_security_project.test.admin_features_package. All values must be known after apply, so this is always a bug in the provider and should be
│ reported in the provider's own repository. Terraform will still save the other known object values in the state.
╵
╷
│ Error: Provider returned invalid result object after apply
│
│ After the apply operation, the provider still indicated an unknown value for ec_security_project.test.product_types. All values must be known after apply, so this is always a bug in the provider and should be reported in
│ the provider's own repository. Terraform will still save the other known object values in the state.
╵
Terraform definition
resource "ec_security_project" "test" {
name = "my-security-project"
region_id = "aws-us-east-1"
# potentially includes admin_features_package and/or product_types
}Steps to Reproduce
- Create a Terraform configuration with an
ec_security_projectresource - Set
admin_features_packageand/orproduct_typesattributes (or rely on defaults) - Run
terraform apply - Observe the error about unknown values after apply
Context
This prevents successful creation of security projects via Terraform. The resource is created on the Elastic Cloud side, but Terraform fails to complete the apply operation cleanly, leaving the state in a partially updated condition.
Possible Solution
Looking at ec/ecresource/projectresource/security.go:
The Read() function (lines 225-292) successfully reads most attributes from the API response but does not populate the admin_features_package or product_types fields from resp.JSON200. These fields need to be read from the API response and set on the model, similar to how other attributes like name, region_id, alias, etc. are handled.
The fields are sent during Create() (lines 110-112 for admin_features_package and lines 114-130 for product_types), but they're never read back from the API response in the Read() function, causing them to remain unknown after the create operation completes.
Your Environment
- Version used: 0.12.2-dev (current master branch)
- Running against Elastic Cloud SaaS or Elastic Cloud Enterprise and version: Elastic Cloud SaaS
- Environment name and version: Terraform v1.x+, Go 1.21+
- Operating System and version: macOS/Linux