Skip to content

Commit beb3e70

Browse files
committed
DOM-54018 Allow GCP access to flyte-dataplane IAM
- Allow GCP tokens with a custom audience matching the string {deploy_id}-flyte-gcp-{random_id} to access Flyte blobs Inspired by policy definition at https://jason-umiker.medium.com/cross-cloud-identities-between-gcp-and-aws-from-gke-and-or-eks-182652bddadb NOTE: jwt validation usually takes into account several factors - issuer - audience - signature - subject - scope - custom claims This policy verifies only the "aud" claim in the token, which in theory is spoofable by anyone using GCP to produce tokens. Therefore, include a random piece of data in the "aud" value that only the control plane will know. When generating executions on remote data planes (by dispatcher / workload operator), this value will be passed so that tokens produced from GCP will have this shared value. To do so requires exporting the value from the terraform code into the catalog and through to Nucleus
1 parent bf072e6 commit beb3e70

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

modules/flyte/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
| Name | Version |
1515
|------|---------|
1616
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |
17+
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
1718

1819
## Modules
1920

@@ -36,6 +37,7 @@ No modules.
3637
| [aws_s3_bucket_policy.flyte_metadata](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
3738
| [aws_s3_bucket_server_side_encryption_configuration.flye_metadata_encryption](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
3839
| [aws_s3_bucket_server_side_encryption_configuration.flyte_data_encryption](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
40+
| [random_id.server](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
3941
| [aws_caller_identity.aws_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
4042
| [aws_iam_policy_document.flyte_controlplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
4143
| [aws_iam_policy_document.flyte_data](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

modules/flyte/iam.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ resource "aws_iam_role_policy_attachment" "flyte_controlplane" {
5656
policy_arn = aws_iam_policy.flyte_controlplane.arn
5757
}
5858

59+
resource "random_id" "server" {
60+
keepers = {
61+
# Generate a new id each time there's a new deploy id (which should never occur)
62+
deploy_id = local.deploy_id
63+
}
64+
65+
byte_length = 8
66+
}
67+
5968
resource "aws_iam_role" "flyte_dataplane" {
6069
name = "${local.deploy_id}-flyte-dataplane"
6170
assume_role_policy = jsonencode({
@@ -91,6 +100,18 @@ resource "aws_iam_role" "flyte_dataplane" {
91100
}
92101
}
93102
},
103+
{
104+
Action = "sts:AssumeRoleWithWebIdentity"
105+
Effect = "Allow"
106+
Principal = {
107+
Federated = "accounts.google.com"
108+
}
109+
Condition : {
110+
StringEquals : {
111+
"accounts.google.com:aud" : "${local.deploy_id}-flyte-gcp-${random_id.server.hex}"
112+
}
113+
}
114+
},
94115
]
95116
})
96117
}

modules/flyte/outputs.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ output "eks" {
55
data_bucket = aws_s3_bucket.flyte_data.bucket
66
controlplane_role_arn = aws_iam_role.flyte_controlplane.arn
77
dataplane_role_arn = aws_iam_role.flyte_dataplane.arn
8+
gcp_token_audience = "${local.deploy_id}-flyte-gcp-${random_id.server.hex}"
89
}
910
}

modules/flyte/versions.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ terraform {
99
source = "hashicorp/aws"
1010
version = "~> 5.0"
1111
}
12+
random = {
13+
source = "hashicorp/random"
14+
version = "~> 3.0"
15+
}
1216
}
1317
}

0 commit comments

Comments
 (0)