hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
248 stars 113 forks source link

awscc_location_api_key : optional keys marked required for creation #1721

Open quixoticmonk opened 3 months ago

quixoticmonk commented 3 months ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

Affected Resource(s)

Terraform Configuration Files

The configuration below are the inputs required per schema. The expiry based inputs are required based on the API response when a Terraform apply is performed.

resource "awscc_location_api_key" "example" {
  key_name = "example_key"
  description = "Example Location API key"
  restrictions = {
    allow_actions = ["geo:GetMap*","geo:GetPlace"]
    allow_resources = ["arn:aws:geo:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:map/ExampleMap*"]

  }
}

Debug Output

Panic Output

Expected Behavior

The resource should be created without any errors.

Actual Behavior

awscc_location_api_key.example: Creating...
╷
│ Error: AWS SDK Go Service Operation Incomplete
│
│   with awscc_location_api_key.example,
│   on main.tf line 1, in resource "awscc_location_api_key" "example":
│    1: resource "awscc_location_api_key" "example" {
│
│ Waiting for Cloud Control API service CreateResource operation completion returned: waiter
│ state transitioned to FAILED. StatusMessage: Invalid request provided: At least one of the
│ following fields must be set: 'ExpireTime', 'NoExpiry'. (Service: Location, Status Code: 400,
│ Request ID: ef69e495-81fa-47e2-bbb1-b11de593b8ce). ErrorCode: InvalidRequest
╵

Steps to Reproduce

  1. terraform apply

Important Factoids

References

breathingdust commented 3 months ago

The Upstream API requires one of ExpireTime or NoExpiry to be set however both attributes are specified as optional in the schema.

I believe this schema should support oneOf so this could be handled better in the provider.

quixoticmonk commented 2 months ago

Opened an internal ticket with the service team on the optional fields.

wellsiau-aws commented 2 weeks ago

@breathingdust , I believe we still need to handle oneOf in the emitter.go to fully support this scenario?

I noticed that awscc_ssmcontacts_plan uses oneOf and these attributes are marked as optional still: https://github.com/hashicorp/terraform-provider-awscc/blob/31700f73fb64ce1f8ff61d4c6dc567f95eb5fb61/internal/service/cloudformation/schemas/AWS_SSMContacts_Plan.json#L120-L133