Skip to content

Instantly share code, notes, and snippets.

@rakodev
Created October 19, 2021 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakodev/4ae1a1bf1dd607e97d612b714f478cb8 to your computer and use it in GitHub Desktop.
Save rakodev/4ae1a1bf1dd607e97d612b714f478cb8 to your computer and use it in GitHub Desktop.
Give ReadOnlyAccess to this account to another AWS account. Replace <ACCOUNT_ID> by the AWS account ID you want to give access.
data "aws_iam_policy_document" "instance_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["<ACCOUNT_ID>"]
}
}
}
resource "aws_iam_role" "api_gateway_cross_account_role" {
name = "apigateway-crossaccount-role"
assume_role_policy = data.aws_iam_policy_document.instance_assume_role_policy.json
}
resource "aws_iam_role_policy_attachment" "sam_api_automation_policy_attach" {
role = aws_iam_role.api_gateway_cross_account_role.name
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment