Open rmalecky opened 1 month ago
@rmalecky , thanks for reporting this issue. I couldn't find reference that explicitly stated that member_ability
can be an empty list.
I tried to replicate this by calling CCAPI directly as shown below:
state.json
{
"CreatorDisplayName": "creator",
"CreatorMemberAbilities": [
"CAN_QUERY",
"CAN_RECEIVE_RESULTS"
],
"CreatorPaymentConfiguration": {
"QueryCompute": {
"IsResponsible": true
}
},
"Description": "Created with Terraform",
"Members": [
{
"AccountId": "204034886740",
"DisplayName": "Account 204034886740",
"MemberAbility" : []
}
],
"Name": "Created with Terraform",
"QueryLogStatus": "ENABLED"
}
CCAPI call:
aws cloudcontrol create-resource \
> --type-name AWS::CleanRooms::Collaboration \
> --desired-state file://state.json
An error occurred (ValidationException) when calling the CreateResource operation: Model validation failed (#/Members/0: required key [MemberAbilities] not found
#/Members/0: extraneous key [MemberAbility] is not permitted)
@wellsiau-aws Thanks for engaging so quickly. There is a bug in you state file. The key is "Members"[*]."MemberAbilities"
, you have "Members"[*]."MemberAbility"
ups, you are right! @rmalecky , I was able to successfully run this via CCAPI:
state.json
{
"CreatorDisplayName": "creator",
"CreatorMemberAbilities": [
"CAN_QUERY",
"CAN_RECEIVE_RESULTS"
],
"CreatorPaymentConfiguration": {
"QueryCompute": {
"IsResponsible": true
}
},
"Description": "Created with Terraform",
"Members": [
{
"AccountId": "411257146414",
"DisplayName": "Account 411257146414",
"MemberAbilities" : []
}
],
"Name": "Created with Terraform",
"QueryLogStatus": "ENABLED"
}
I think this part of the code today is causing Terraform to return nil.
I am sure there's a history behind it, cc @ewbankkit for additional comments.
It looks like that logic has been in there from the very early days (https://github.com/hashicorp/terraform-provider-awscc/pull/32, which introduced use of terraform-plugin-framework
). I think it was informed by experience from terraform-provider-aws
that an empty array and nil
array (or missing array) are functionally equivalent.
Community Note
Terraform CLI and Terraform AWS Cloud Control Provider Version
Terraform v1.8.4 on darwin_amd64
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
https://gist.github.com/rmalecky/a7f49c99f58ed4542805026d8633163e
Expected Behavior
I expected the above HCL to create an AWS Clean Rooms Collaboration.
Actual Behavior
I get an error stating that Members.MemberAbilities key is missing
Steps to Reproduce
run the included HCL script with an AWS account is an AWS region AWS Clean Rooms is supported (us-east-1, us-east-2, us-west-2, ..)
terraform apply
Important Factoids
The Members Abilities is a required field, if no abilities are included for a member the call must pass an empty array. https://docs.aws.amazon.com/clean-rooms/latest/apireference/API_MemberSpecification.html#API-Type-MemberSpecification-memberAbilities
Looking at the debug logs the empty array is being dropped before the CC API is called
References