-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Bug]: aws_inspector2_enabler
fails to create on 5.6.0 due to incorrect resource type constant
#32334
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
example fix, no time to do a proper pull request currently unfortunately: diff --git a/internal/service/inspector2/enabler.go b/internal/service/inspector2/enabler.go
index 5ca18829f8..b65d4477fb 100644
--- a/internal/service/inspector2/enabler.go
+++ b/internal/service/inspector2/enabler.go
@@ -536,6 +536,9 @@ func AccountStatuses(ctx context.Context, conn *inspector2.Client, accountIDs []
continue
}
for k, v := range m {
+ if k == "LambdaCode" {
+ k = "LAMBDA_CODE"
+ }
status.ResourceStatuses[types.ResourceScanType(strings.ToUpper(k))] = v.Status
}
results[aws.ToString(a.AccountId)] = status
diff --git a/website/docs/r/inspector2_enabler.html.markdown b/website/docs/r/inspector2_enabler.html.markdown
index 64453a5664..38e2279f74 100644
--- a/website/docs/r/inspector2_enabler.html.markdown
+++ b/website/docs/r/inspector2_enabler.html.markdown
@@ -41,7 +41,7 @@ The following arguments are required:
* `account_ids` - (Required) Set of account IDs.
Can contain one of: the Organization's Administrator Account, or one or more Member Accounts.
* `resource_types` - (Required) Type of resources to scan.
- Valid values are `EC2`, `ECR`, and `LAMBDA`.
+ Valid values are `EC2`, `ECR`, `LAMBDA` and `LAMBDA_CODE`.
At least one item is required.
## Attributes Reference |
I'm seeing this issue with provider 5.7.0. |
Same issue still occurs with provider 5.8.0. |
Also happens with provider 5.10.0 |
This fix worked for me. |
Also happens in provider 5.16.1 |
This is also occurring with 5.17.0. In fact, the AWS provider crashes completely:
|
I'm also seeing this with provider 5.20.0. |
This functionality has been released in v5.22.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Core Version
1.4.6
AWS Provider Version
5.6.0, 5.6.2, be00acc
Affected Resource(s)
aws_inspector2_enabler
Expected Behavior
Applying the above configuration should enable Amazon Inspector, enabling scanning EC2 instances, ECR registries and Lambda functions.
Actual Behavior
The provider correctly enables Inspector with EC2/ECR/Lambda scanning, however after enabling the service, the
resourceEnablerCreate
function (internal/services/inspector2/enabler.go
) checks if it needs to disable any type of resource scans:The
typeEnable
slice contains["EC2", "ECR", "LAMBDA"]
before the for loop runs, the acctStatus.ResourceStatuses map has the keys["EC2", "ECR", "LAMBDA", "LAMBDACODE"]
.After the inner for loop deletes the resource types that should be enabled, we are left with
LAMBDACODE
, which is then passed to theDisable
API call. At this point, the code fails, because the value should beLAMBDA_CODE
, so it fails validation on the AWS API side.This happens because the
AccountStatuses
function (from the same file) used to fetch the values from the API, gets a struct with aLambdaCode
field, and usesstrings.ToUpper
to convert to atypes.ResourceScanType
constant fromjackfan.us.kg/aws/aws-sdk-go-v2/service/inspector2/types
:The correct value for the constant is
LAMBDA_CODE
.Relevant Error/Panic Output Snippet
│ Error: updating Amazon Inspector Enabler ([REDACTED]-EC2:ECR:LAMBDA): operation error Inspector2: Disable, https response error StatusCode: 400, RequestID: [REDACTED], ValidationException: 1 validation error detected: Value at 'resourceTypes' failed to satisfy constraint: Member must satisfy constraint: [Member must satisfy enum value set: [LAMBDA_CODE, LAMBDA, ECR, EC2]]
Terraform Configuration Files
Steps to Reproduce
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: