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

Terraform generates AccessDenied events #15659

Closed
lapkritinis opened this issue Oct 15, 2020 · 7 comments · Fixed by #15481
Closed

Terraform generates AccessDenied events #15659

lapkritinis opened this issue Oct 15, 2020 · 7 comments · Fixed by #15481
Assignees
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@lapkritinis
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.12.29

  • provider.archive v2.0.0
  • provider.aws v3.10.0
  • provider.null v3.0.0
  • provider.random v3.0.0

Affected Resource(s)

  • S3 in generic sense

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

Panic Output

Expected Behavior

It should run without generating AccessDenied events

Actual Behavior

Terraform while running does multiple queries against S3 bucket. Just be clear - I am running with full Administrator rights.
Among all the other requests to same S3 bucket where it presents authorization headers there is one request which seems goes "anonymous"

Here is log snippet:
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5: 2020/10/15 17:10:56 [DEBUG] [aws-sdk-go] DEBUG: Request s3/HeadBucket Details:
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5: ---[ REQUEST POST-SIGN ]-----------------------------
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5: HEAD /com.example.prod.temp HTTP/1.1
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5: Host: s3.eu-central-1.amazonaws.com
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5: User-Agent: aws-sdk-go/1.35.2 (go1.14.5; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.29 (+https://www.terraform.io)
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5:
2020-10-15T17:10:56.606+0300 [DEBUG] plugin.terraform-provider-aws_v3.10.0_x5:

Here is snippet from CloudTrail AccessDenied event:

"eventVersion": "1.07",
"userIdentity": {
"type": "AWSAccount",
"principalId": "",
"accountId": "ANONYMOUS_PRINCIPAL"
},
"eventTime": "2020-10-15T14:10:56Z",
"eventSource": "s3.amazonaws.com",
"eventName": "HeadBucket",
"awsRegion": "eu-central-1",
"sourceIPAddress": "89.xxx.xxx.xxx",
"userAgent": "[aws-sdk-go/1.35.2 (go1.14.5; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.29 (+https://www.terraform.io)]",
"errorCode": "AccessDenied",
"errorMessage": "Access Denied",
"requestParameters": {
"bucketName": "com.example.prod.temp",
"Host": "s3.eu-central-1.amazonaws.com"
},

Steps to Reproduce

I guess run terraform apply in account which has S3 buckets.

Important Factoids

References

  • #0000
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 15, 2020
@lapkritinis
Copy link
Author

p.s. it generates such event for each S3 bucket in region. As we are watching logs for AccessDenied events - its annoying to get spammed every time we do something with terraform :)

@ecktom
Copy link

ecktom commented Oct 27, 2020

Just stumbled about this issue after updating https://github.com/nozaq/terraform-aws-secure-baseline (0.20.0->0.21.0) to comply with CIS Amazon Web Services Foundations v1.3.0

Can confirm the issue occurs, even during terraform plan

Terraform v0.13.4
AWS Provider v3.12.0

{
    "eventVersion": "1.07",
    "userIdentity": {
        "type": "AWSAccount",
        "principalId": "",
        "accountId": "ANONYMOUS_PRINCIPAL"
    },
    "eventTime": "2020-10-27T14:24:27Z",
    "eventSource": "s3.amazonaws.com",
    "eventName": "HeadBucket",
    "awsRegion": "eu-central-1",
    "sourceIPAddress": "**redacted**",
    "userAgent": "[aws-sdk-go/1.35.9 (go1.14.5; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.13.4 (+https://www.terraform.io)]",
    "errorCode": "AccessDenied",
    "errorMessage": "Access Denied",
    "requestParameters": {
        "bucketName": "**redacted**",
        "Host": "**redacted**.s3.eu-central-1.amazonaws.com"
    },
    "responseElements": null,
    "additionalEventData": {
        "CipherSuite": "**redacted**",
        "bytesTransferredIn": 0,
        "x-amz-id-2": "**redacted**",
        "bytesTransferredOut": 243
    },
    "requestID": "**redacted**",
    "eventID": "**redacted**",
    "readOnly": true,
    "resources": [
        {
            "type": "AWS::S3::Object",
            "ARNPrefix": "**redacted**/"
        },
        {
            "accountId": "**redacted**",
            "type": "AWS::S3::Bucket",
            "ARN": "**redacted**"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": false,
    "recipientAccountId": "**redacted**",
    "sharedEventID": "**redacted**",
    "eventCategory": "Data"
}

@lapkritinis
Copy link
Author

I am glad - I am not alone 👍

@ebabani
Copy link
Contributor

ebabani commented Oct 30, 2020

This PR should help with the Headbucket requests: #15481

@bflad bflad added bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 17, 2020
@bflad bflad self-assigned this Nov 17, 2020
@bflad bflad added this to the v3.16.0 milestone Nov 17, 2020
@bflad
Copy link
Contributor

bflad commented Nov 17, 2020

The fix for this has been merged and will release with version 3.16.0 of the Terraform AWS Provider, later this week. Thank you to @ebabani for the implementation. 👍

@ghost
Copy link

ghost commented Nov 18, 2020

This has been released in version 3.16.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 for triage. Thanks!

@ghost
Copy link

ghost commented Dec 17, 2020

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.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
4 participants