forked from UN-SPIDER/burn-severity-mapping-EO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
woof - very confusing oidc string mapping from gcp to aws but hey we …
…got there. read the docs, kids. running into an issue with upload but looks to be on the aws side so we have successfully crossed the moat with oidc
- Loading branch information
Showing
8 changed files
with
122 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,22 +213,57 @@ resource "aws_s3_bucket_object" "assets" { | |
# Set up STS to allow the GCP server to assume a role for AWS secrets | ||
|
||
# Defines who can assume the role. | ||
# Confusing string mapping for the OIDC provider URL (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_iam-condition-keys.html#ck_aud) | ||
# example paylod of our token looks like:/ | ||
# { | ||
# "aud": "sts.amazonaws.com", | ||
# "azp": "117526146749746854545", | ||
# "email": "[email protected]", | ||
# "email_verified": true, | ||
# "exp": 1706551963, | ||
# "iat": 1706548363, | ||
# "iss": "https://accounts.google.com", | ||
# "sub": "117526146749746854545" | ||
# } | ||
# AWS says: aud -> azp, oaud -> aud, sub -> sub | ||
|
||
data "aws_iam_policy_document" "oidc_assume_role_policy" { | ||
statement { | ||
actions = ["sts:AssumeRoleWithWebIdentity"] | ||
actions = [ | ||
"sts:AssumeRoleWithWebIdentity" | ||
] | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "Federated" | ||
identifiers = ["arn:aws:iam::${var.aws_account_id}:oidc-provider/${var.oidc_provider_domain_url}"] | ||
# identifiers = ["arn:aws:iam::${var.aws_account_id}:oidc-provider/${var.oidc_provider_domain_url}"] | ||
identifiers = ["accounts.google.com"] | ||
} | ||
|
||
condition { | ||
test = "StringEquals" | ||
variable = "${var.oidc_provider_domain_url}:sub" | ||
|
||
values = [ | ||
"system:serviceaccount:${var.google_project_number}.svc.id.goog[default/${var.gcp_service_account_s3_email}]" | ||
"${var.gcp_cloud_run_client_id}" | ||
] | ||
} | ||
|
||
condition { | ||
test = "StringEquals" | ||
variable = "${var.oidc_provider_domain_url}:aud" | ||
|
||
values = [ | ||
"${var.gcp_cloud_run_client_id}" | ||
] | ||
} | ||
|
||
condition { | ||
test = "StringEquals" | ||
variable = "${var.oidc_provider_domain_url}:oaud" | ||
|
||
values = [ | ||
"sts.amazonaws.com" | ||
] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters