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

request_reason in provider is not setting values in audit logs #10271

Closed
imrannayer opened this issue Oct 6, 2021 · 7 comments
Closed

request_reason in provider is not setting values in audit logs #10271

imrannayer opened this issue Oct 6, 2021 · 7 comments
Assignees
Labels

Comments

@imrannayer
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 me too comments, 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.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.0.5
on darwin_amd64

Affected Resource(s)

  • provider "google"

  • provider "google-beta"

Terraform Configuration Files

provider "google" {
  impersonate_service_account = local.tf_sa
  request_reason = "somereason"
}

provider "google-beta" {
  impersonate_service_account = local.tf_sa
  request_reason = "somereason"
}

Debug Output

Panic Output

Expected Behavior

Audit log is suppose to show value passed to request_reason

      "requestAttributes": {
        "time": "2021-10-06T19:12:14.200660011Z",
        "reason": "somereason",
        "auth": {}
      },

Actual Behavior

Audit log is missing value reason: somereason

Steps to Reproduce

  1. terraform apply

Important Factoids

References

request_reason

  • #0000
@imrannayer imrannayer added the bug label Oct 6, 2021
@imrannayer
Copy link
Author

Looks like provider is sending information in API. See trace bwlow

---[ REQUEST ]---------------------------------------
POST /storage/v1/b?alt=json&prettyPrint=false&project=myprj HTTP/1.1^M
Host: storage.googleapis.com^M
User-Agent: google-api-go-client/0.5 Terraform/1.0.5 (+https://www.terraform.io) Terraform-Plugin-SDK/2.5.0 terraform-provider-google/3.87.0^M
Content-Length: 160^M
Content-Type: application/json^M
X-Goog-Api-Client: gl-go/1.16.2 gdcl/20210830^M
X-Goog-Request-Reason: somereason^M
Accept-Encoding: gzip^M
^M
{
 "iamConfiguration": {
  "uniformBucketLevelAccess": {
   "enabled": true
  }
 },
 "lifecycle": {
  "rule": []
 },
 "location": "US",
 "name": "sin-smoke-testing",
 "storageClass": "STANDARD"
}

@edwardmedia edwardmedia self-assigned this Oct 6, 2021
@edwardmedia
Copy link
Contributor

edwardmedia commented Oct 6, 2021

@imrannayer I guess recording the reason into the audit log is handled by the api. From the provider's perspective, it works as designed as you can see here. Can you file an issue against api? Let me know what you think

@imrannayer
Copy link
Author

I tested this feature using gcloud command and it is working fine. So I am not sure is this is an API issue. Here is how I tested it.

gcloud config set core/request_reason "myreason"
gcloud secrets create dbpassword

@edwardmedia is it possible if you can create an issue for API team as I am not sure which API it will be.

@edwardmedia
Copy link
Contributor

@imrannayer I see what you mean. I guess it depends on which service you try to use. It seems not all APIs support it. To verify it, can you run below command to see if that is the same?

gcloud compute instances create myvm

@imrannayer
Copy link
Author

Got it. Thanks @edwardmedia for checking. Just tested creating secret using Terraform and it is showing request_reason in audit logs.
I guess storage apis are not supporting it.

@edwardmedia
Copy link
Contributor

@imrannayer yes, I think this feature is case by case. For secrets, yes. But for compute instance and storage. not yet in their APIs. For the provider side, it is already implemented. To request the feature, I guess you need to reach out to the individual api service support. Let me close this issue. You may reopen if you need to continue the investigation. Thank you

@github-actions
Copy link

github-actions bot commented Nov 7, 2021

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants