Skip to content

Commit

Permalink
add domino repo arn (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcwhorter-ddl authored Nov 18, 2024
1 parent 689843f commit 5c832a5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ No modules.
| [aws_iam_role.domino_sagemaker_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.role_permissions_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.read_domino_environments](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.role_permissions_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.role_trust_policy](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 |
Expand All @@ -107,6 +108,7 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_bucket"></a> [bucket](#input\_bucket) | S3 bucket to use for sagemaker deployment model artifacts (in the target AWS account). Defaults to the value specified by `resource_identifier` plus the suffix `-{aws_account_id}.` | `string` | `null` | no |
| <a name="input_domino_environments_repository_arn"></a> [domino\_environments\_repository\_arn](#input\_domino\_environments\_repository\_arn) | ARN for the Domino environments repository. ONLY needed if deploying in the SAME AWS account as Domino. | `string` | n/a | yes |
| <a name="input_domino_external_deployments_role_arn"></a> [domino\_external\_deployments\_role\_arn](#input\_domino\_external\_deployments\_role\_arn) | ARN for the Domino external deployments IAM role (in the domino AWS account) | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | AWS region in which to create the sagemaker resources | `string` | n/a | yes |
| <a name="input_repository"></a> [repository](#input\_repository) | ECR repository name to use for sagemaker deployment images (in the target AWS account). Defaults to the value specified by `resource_identifier`. | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion bin/pre-commit/check-aws-partition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exec 1>&2
check_aws_partition() {
declare -A failed_files
exclude_patterns=("policy/AWSLambdaExecute")
exclude_files=("README.md")
exclude_files=("README.md" "tests/test.tftest.hcl")

for file in "$@"; do
if grep -q "arn:aws" "${file}"; then
Expand Down
18 changes: 18 additions & 0 deletions role_policies.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
data "aws_iam_policy_document" "read_domino_environments" {
count = var.domino_environments_repository_arn != null ? 1 : 0
statement {
sid = "EcrRegistryReadDominoEnvironments"
effect = "Allow"
actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
]
resources = [
var.domino_environments_repository_arn,
"${var.domino_environments_repository_arn}*",
]
}
}

data "aws_iam_policy_document" "role_permissions_policy" {
source_policy_documents = var.domino_environments_repository_arn != null ? [data.aws_iam_policy_document.read_domino_environments[0].json] : []
statement {
sid = "StsAllowSelfAssumeRole"
effect = "Allow"
Expand Down
1 change: 1 addition & 0 deletions tests/test.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ run "create_resources" {
variables {
resource_identifier = run.setup_tests.resource_identifier
domino_external_deployments_role_arn = run.setup_tests.domino_external_deployments_role_arn
domino_environments_repository_arn = "arn:aws:ecr:us-east-1:763104351884:repository/pytorch-inference"
region = "us-east-1"
}
}
18 changes: 12 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ variable "resource_identifier" {
default = "domino-sagemaker"
}

variable "domino_external_deployments_role_arn" {
type = string
description = "ARN for the Domino external deployments IAM role (in the domino AWS account)"
nullable = false
}

variable "region" {
type = string
description = "AWS region in which to create the sagemaker resources"
Expand Down Expand Up @@ -41,3 +35,15 @@ variable "role_name" {
nullable = true
default = null
}

variable "domino_external_deployments_role_arn" {
type = string
description = "ARN for the Domino external deployments IAM role (in the domino AWS account)"
nullable = false
}

variable "domino_environments_repository_arn" {
type = string
description = "ARN for the Domino environments repository. ONLY needed if deploying in the SAME AWS account as Domino."
nullable = true
}

0 comments on commit 5c832a5

Please sign in to comment.