-
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
b-fixed forced destroy of securitylake when meta_store_role_arn changes #36874
base: main
Are you sure you want to change the base?
b-fixed forced destroy of securitylake when meta_store_role_arn changes #36874
Conversation
Community NoteVoting for Prioritization
For Submitters
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome @joelmccoy 👋
It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.
Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.
Thanks again, and welcome to the community! 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @joelmccoy. It looks good. I have a few suggestions
resource "aws_iam_role" "meta_store_manager_v1" { | ||
name = "AmazonSecurityLakeMetaStoreManagerV1" | ||
path = "/service-role/" | ||
assume_role_policy = <<POLICY | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [{ | ||
"Sid": "AllowLambda", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
}, | ||
"Action": "sts:AssumeRole" | ||
}] | ||
} | ||
POLICY | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "datalake_v1" { | ||
role = aws_iam_role.meta_store_manager_v1.name | ||
policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AmazonSecurityLakeMetastoreManager" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this Role is only used in the testAccDataLakeConfig_metaStore
and testAccDataLakeConfig_metaStoreUpdate
, it would be better to only include it in those configurations, rather than for all tests
Name = %[1]q | ||
} | ||
|
||
depends_on = [aws_iam_role.meta_store_manager] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since meta_store_manager_role_arn
already refers to aws_iam_role.meta_store_manager
, this depends_on
is redundant.
tags = { | ||
Name = %[1]q | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags
can be removed, since it's not relevant to this test
@gdavison Good feedback. I implemented the changes... but in the process I discovered an issue with the UpdateDataLake api call. When you specify a new role it just adds this new role to the Data Lake Administrators list (in the LakeFormation Service) but it doesn't remove the previous role. Essentially the SecurityLake API is doing some LakeFormation calls under the hood and it is leaving dangling resources in LakeFormation that can potentially cause some issues. Here is an example of the flow:
This becomes an issue because if you delete the IAM role1 or role2 ALL SecurityLake operations will fail (yikes). See below for error that is returned. I discovered this in my tests when i removed the v1 role out of the basic config. It seems to check this Lakeformation admin list and will fail if any of the admin IAM roles do not exist. I think this is also the case for Deleting Security Lake Resource. It seems to leave this dangling Admin Assignment in Lakeformation. The only way to change these admins I believe is through this LakeFormation PutDataLakeSettings. A hacky way around this is would be to make some lakeformation calls in the terraform provider to do the cleanup on a meta_store_role_arn change. But that doesn't feel right and I think this should be fixed upstream in the APIs. Agree/disagree? |
Good find, @joelmccoy. We do have a number of cases where we need to do some cleanup to "help" AWS services. For example,
Do you know if there's a delayed process on the AWS side that eventually removes the role from Lake Formation? If so, we could wait for that. Otherwise, the provider may have to reach across service boundaries. |
@gdavison It doesn't seem to ever get deleted. If it is a sane approach to add a helper to clean up lingering edit: Also to note, the helper logic would need to GetDataLakeSettings, remove the meta_store_role from the response, and then PutDataLakeSettings. There is no Update call for this operation, which makes it kind of ugly. |
Description
This change updates the aws_securitylake_data_lake logic so that when the attribute
meta_store_manager_role_arn
is changed it does not require a delete of the entire data lake. The UpdateDataLake recently included a change where you can update the metaStoreManagerRoleArn with this API call. The stringplanmodifier.RequiresReplace is no longer necessary.Relations
Closes #36831
References
N/A
Output from Acceptance Testing