-
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]: Org Trail resource creation failed for CloudTrail Delegated Administrator #28440
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
I have got the same issue. |
Have the exact same issue occurring as the original poster, when i go into the AWS console i can see the trail has been created but has not been activated. If i click start logging it starts up fine, so could be the issue be a timing related one. Also if i run the script a second i get the exact same output as F-Xu above, Terraform doesn't think it has already created the trail so its attempting to create it again. |
I think I might have found a solution (more of a workaround really) to this issue in the interim, at least until the AWS Terraform provider can be updated to properly manage resources created from delegated administrator accounts. This was inspired by a bit of AWS sample code for using delegated administration with GuardDuty. You can define a separate terraform provider for your management account provider "aws" {
region = "us-east-1"
profile = "security-acct"
}
provider "aws" {
alias = "mgmt"
profile = "management-acct"
region = "us-east-1"
} and use it to directly manage just the resource "aws_cloudtrail" "org_trail" {
provider = aws.mgmt
name = "org_trail"
...
} I believe there is an underlying issue with the way AWS has implemented the GetTrail action that prevents the AWS terraform provider from implementing this properly though. It seems that Cloudtrail delegated administrator accounts don't have the ability to perform
If you run {
"trailList": [
{
"Name": "regular-trail-1",
...
"TrailARN": "arn:aws:cloudtrail:us-east-1:<SECURITY ACCOUNT ID>:trail/regular-trail-1",
...
},
{
"Name": "regular-trail-2",
...
"TrailARN": "arn:aws:cloudtrail:us-east-1:<SECURITY ACCOUNT ID>:trail/regular-trail-2",
...
},
{
"Name": "org_trail",
...
"TrailARN": "arn:aws:cloudtrail:us-east-1:<MANAGEMENT ACCOUNT ID>:trail/org_trail",
...
}
]
}
but when you run
When you try to run the same command but from your management account (i.e. |
As a follow up to @andrewnicolalde, if you run So it would seem a simple fix would be to update the terraform aws provider to use the ARN of the trail instead of the name. The other option would be to use the describe-trails without any option, which DOES return the org trail, and then iterate over the values find the one that matches the Name that is being requested. Not as efficient, but given that the vast majority of users are not going to have more than a small number of trails defined (there isn't much of a reasons to do so) it shouldn't be an issue. |
Could you merge the PR please? Have the same issue |
and we too, so just waiting ( |
I tried the workaround suggested by @andrewnicolalde and it didn't work. Could you please merge the PR- would make it amazing if this got fixed. 🥺 |
Having the same issue. Upvoting for fix/PR |
Having same issue. Upvoting |
Having the same issue. Upvoting. |
Upvoting. 🔥 |
@bflad @ewbankkit This is impacting quite a few people and is critical functionality for cloudtrail management Thank you |
I have the same issue. Upvoting 👍🏻 |
Upvoting |
This functionality has been released in v5.25.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.3.6
AWS Provider Version
4.47.0
Affected Resource(s)
aws_cloudtrail
Expected Behavior
Actual Behavior
When Terraform applies, it's failed when it try to enable logging it in the Delegated Account because it's did not find the trail.
After successfully creation, The AWS provider seems try to enable the trail locally (in the Delegated account) instead to referer to the trail 'stored' in the Management Account. The ARN in the below log explains the bug.
Relevant Error/Panic Output Snippet
'111111111111' is the Delegated Account ID.
Terraform Configuration Files
Steps to Reproduce
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-delegated-administrator.html
Would you like to implement a fix?
No
The text was updated successfully, but these errors were encountered: