-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOM-54483] Link flyte roles to flyte buckets, add permissions (#218)
* link flyte roles to buckets * new submodule for flyte * try hacking infro deploy * update outputs * role perm changes * move flyte module outside of infra * update docs after merge * remove kms * default to AES256 encryption * add namespace vars to flyte (#221) * make variable for service account names * remove one level of nesting for flyte outputs
- Loading branch information
Showing
19 changed files
with
351 additions
and
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# flyte | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 | | ||
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.1.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_iam_policy.flyte_controlplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | ||
| [aws_iam_policy.flyte_dataplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | ||
| [aws_iam_role.flyte_controlplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | ||
| [aws_iam_role.flyte_dataplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | ||
| [aws_iam_role_policy_attachment.flyte_controlplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | ||
| [aws_iam_role_policy_attachment.flyte_dataplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | ||
| [aws_s3_bucket.flyte_data](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | ||
| [aws_s3_bucket.flyte_metadata](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | ||
| [aws_s3_bucket_policy.flyte_data](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | | ||
| [aws_s3_bucket_policy.flyte_metadata](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | | ||
| [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 | | ||
| [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 | | ||
| [aws_iam_policy_document.flyte_controlplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | ||
| [aws_iam_policy_document.flyte_data](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | ||
| [aws_iam_policy_document.flyte_dataplane](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | ||
| [aws_iam_policy_document.flyte_metadata](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | ||
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_compute_namespace"></a> [compute\_namespace](#input\_compute\_namespace) | Name of Domino compute namespace for this deploy | `string` | n/a | yes | | ||
| <a name="input_eks_info"></a> [eks\_info](#input\_eks\_info) | cluster = {<br> specs {<br> name = Cluster name.<br> account\_id = AWS account id where the cluster resides.<br> }<br> oidc = {<br> arn = OIDC provider ARN.<br> url = OIDC provider url.<br> cert = {<br> thumbprint\_list = OIDC cert thumbprints.<br> url = OIDC cert URL.<br> }<br> } | <pre>object({<br> cluster = object({<br> specs = object({<br> name = string<br> account_id = string<br> })<br> oidc = object({<br> arn = string<br> url = string<br> cert = object({<br> thumbprint_list = list(string)<br> url = string<br> })<br> })<br> })<br> })</pre> | n/a | yes | | ||
| <a name="input_force_destroy_on_deletion"></a> [force\_destroy\_on\_deletion](#input\_force\_destroy\_on\_deletion) | Whether to force destroy flyte s3 buckets on deletion | `bool` | `true` | no | | ||
| <a name="input_platform_namespace"></a> [platform\_namespace](#input\_platform\_namespace) | Name of Domino platform namespace for this deploy | `string` | n/a | yes | | ||
| <a name="input_serviceaccount_names"></a> [serviceaccount\_names](#input\_serviceaccount\_names) | Service account names for Flyte | <pre>object({<br> datacatalog = optional(string, "datacatalog")<br> flyteadmin = optional(string, "flyteadmin")<br> flytepropeller = optional(string, "flytepropeller")<br> })</pre> | `{}` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_eks"></a> [eks](#output\_eks) | Flyte eks info | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
resource "aws_iam_role" "flyte_controlplane" { | ||
name = "${local.deploy_id}-flyte-controlplane" | ||
assume_role_policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Action = "sts:AssumeRoleWithWebIdentity" | ||
Effect = "Allow" | ||
Principal = { | ||
Federated = local.oidc_provider_arn | ||
} | ||
Condition : { | ||
StringEquals : { | ||
"${trimprefix(local.oidc_provider_url, "https://")}:aud" : "sts.amazonaws.com", | ||
"${trimprefix(local.oidc_provider_url, "https://")}:sub" : [ | ||
"system:serviceaccount:${var.platform_namespace}:${var.serviceaccount_names.flyteadmin}", | ||
"system:serviceaccount:${var.platform_namespace}:${var.serviceaccount_names.flytepropeller}", | ||
] | ||
} | ||
} | ||
}, | ||
] | ||
}) | ||
} | ||
|
||
data "aws_iam_policy_document" "flyte_controlplane" { | ||
statement { | ||
effect = "Allow" | ||
resources = [ | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_metadata.bucket}/*", | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_metadata.bucket}" | ||
] | ||
actions = [ | ||
"s3:PutObject", | ||
"s3:GetObject", | ||
"s3:ListBucket", | ||
] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "flyte_controlplane" { | ||
name = "${local.deploy_id}-flyte-controlplane" | ||
policy = data.aws_iam_policy_document.flyte_controlplane.json | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "flyte_controlplane" { | ||
role = aws_iam_role.flyte_controlplane.name | ||
policy_arn = aws_iam_policy.flyte_controlplane.arn | ||
} | ||
|
||
resource "aws_iam_role" "flyte_dataplane" { | ||
name = "${local.deploy_id}-flyte-dataplane" | ||
assume_role_policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Action = "sts:AssumeRoleWithWebIdentity" | ||
Effect = "Allow" | ||
Principal = { | ||
Federated = local.oidc_provider_arn | ||
} | ||
Condition : { | ||
StringEquals : { | ||
"${trimprefix(local.oidc_provider_url, "https://")}:aud" : "sts.amazonaws.com", | ||
"${trimprefix(local.oidc_provider_url, "https://")}:sub" : [ | ||
"system:serviceaccount:${var.platform_namespace}:${var.serviceaccount_names.datacatalog}", | ||
"system:serviceaccount:${var.compute_namespace}:*" | ||
] | ||
} | ||
} | ||
}, | ||
] | ||
}) | ||
} | ||
|
||
data "aws_iam_policy_document" "flyte_dataplane" { | ||
statement { | ||
effect = "Allow" | ||
resources = [ | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_metadata.bucket}/*", | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_metadata.bucket}", | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_data.bucket}/*", | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_data.bucket}", | ||
] | ||
|
||
actions = [ | ||
"s3:PutObject", | ||
"s3:GetObject", | ||
"s3:ListBucket" | ||
] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "flyte_dataplane" { | ||
name = "${local.deploy_id}-flyte-dataplane" | ||
policy = data.aws_iam_policy_document.flyte_dataplane.json | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "flyte_dataplane" { | ||
role = aws_iam_role.flyte_dataplane.name | ||
policy_arn = aws_iam_policy.flyte_dataplane.arn | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "aws_partition" "current" {} | ||
|
||
locals { | ||
deploy_id = var.eks_info.cluster.specs.name | ||
oidc_provider_arn = var.eks_info.cluster.oidc.arn | ||
oidc_provider_url = var.eks_info.cluster.oidc.cert.url | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "eks" { | ||
description = "Flyte eks info" | ||
value = { | ||
metadata_bucket = aws_s3_bucket.flyte_metadata.bucket | ||
data_bucket = aws_s3_bucket.flyte_data.bucket | ||
controlplane_role_arn = aws_iam_role.flyte_controlplane.arn | ||
dataplane_role_arn = aws_iam_role.flyte_dataplane.arn | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
resource "aws_s3_bucket" "flyte_metadata" { | ||
bucket = "${local.deploy_id}-flyte-metadata" | ||
force_destroy = var.force_destroy_on_deletion | ||
object_lock_enabled = false | ||
} | ||
|
||
data "aws_iam_policy_document" "flyte_metadata" { | ||
statement { | ||
effect = "Deny" | ||
|
||
resources = [ | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_metadata.bucket}", | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_metadata.bucket}/*", | ||
] | ||
|
||
actions = ["s3:*"] | ||
|
||
condition { | ||
test = "Bool" | ||
variable = "aws:SecureTransport" | ||
values = ["false"] | ||
} | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["*"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_policy" "flyte_metadata" { | ||
bucket = aws_s3_bucket.flyte_metadata.id | ||
policy = data.aws_iam_policy_document.flyte_metadata.json | ||
} | ||
|
||
resource "aws_s3_bucket_server_side_encryption_configuration" "flye_metadata_encryption" { | ||
bucket = aws_s3_bucket.flyte_metadata.bucket | ||
rule { | ||
apply_server_side_encryption_by_default { | ||
sse_algorithm = "AES256" | ||
} | ||
bucket_key_enabled = false | ||
} | ||
|
||
lifecycle { | ||
ignore_changes = [ | ||
rule, | ||
] | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "flyte_data" { | ||
bucket = "${local.deploy_id}-flyte-data" | ||
force_destroy = var.force_destroy_on_deletion | ||
object_lock_enabled = false | ||
} | ||
|
||
data "aws_iam_policy_document" "flyte_data" { | ||
statement { | ||
effect = "Deny" | ||
|
||
resources = [ | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_data.bucket}", | ||
"arn:${data.aws_partition.current.partition}:s3:::${aws_s3_bucket.flyte_data.bucket}/*", | ||
] | ||
|
||
actions = ["s3:*"] | ||
|
||
condition { | ||
test = "Bool" | ||
variable = "aws:SecureTransport" | ||
values = ["false"] | ||
} | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["*"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_policy" "flyte_data" { | ||
bucket = aws_s3_bucket.flyte_data.id | ||
policy = data.aws_iam_policy_document.flyte_data.json | ||
} | ||
|
||
resource "aws_s3_bucket_server_side_encryption_configuration" "flyte_data_encryption" { | ||
bucket = aws_s3_bucket.flyte_data.bucket | ||
rule { | ||
apply_server_side_encryption_by_default { | ||
sse_algorithm = "AES256" | ||
} | ||
bucket_key_enabled = false | ||
} | ||
|
||
lifecycle { | ||
ignore_changes = [ | ||
rule, | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
variable "force_destroy_on_deletion" { | ||
description = "Whether to force destroy flyte s3 buckets on deletion" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "eks_info" { | ||
description = <<EOF | ||
cluster = { | ||
specs { | ||
name = Cluster name. | ||
account_id = AWS account id where the cluster resides. | ||
} | ||
oidc = { | ||
arn = OIDC provider ARN. | ||
url = OIDC provider url. | ||
cert = { | ||
thumbprint_list = OIDC cert thumbprints. | ||
url = OIDC cert URL. | ||
} | ||
} | ||
EOF | ||
type = object({ | ||
cluster = object({ | ||
specs = object({ | ||
name = string | ||
account_id = string | ||
}) | ||
oidc = object({ | ||
arn = string | ||
url = string | ||
cert = object({ | ||
thumbprint_list = list(string) | ||
url = string | ||
}) | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
variable "platform_namespace" { | ||
description = "Name of Domino platform namespace for this deploy" | ||
type = string | ||
} | ||
|
||
variable "compute_namespace" { | ||
description = "Name of Domino compute namespace for this deploy" | ||
type = string | ||
} | ||
|
||
variable "serviceaccount_names" { | ||
description = "Service account names for Flyte" | ||
type = object({ | ||
datacatalog = optional(string, "datacatalog") | ||
flyteadmin = optional(string, "flyteadmin") | ||
flytepropeller = optional(string, "flytepropeller") | ||
}) | ||
|
||
default = {} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_providers { | ||
null = { | ||
source = "hashicorp/null" | ||
version = ">= 3.1.0" | ||
} | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.0" | ||
} | ||
} | ||
} |
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
Oops, something went wrong.