Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #22

Merged
merged 1 commit into from
May 30, 2024
Merged

Dev #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions aws_iam_policy_document.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ data "aws_iam_policy_document" "assume_role_sfn_state_machine_rekognition_detect
}
}

data "aws_iam_policy_document" "assume_role_sfn_state_machine_rekognition_detect_text" {
statement {
actions = [
"sts:AssumeRole"
]
effect = "Allow"
principals {
identifiers = ["states.amazonaws.com"]
type = "Service"
}
}
}

data "aws_iam_policy_document" "sfn_state_machine_rekognition_detect_faces" {
statement {
actions = [
Expand Down Expand Up @@ -189,3 +202,38 @@ data "aws_iam_policy_document" "sfn_state_machine_rekognition_detect_protective_
]
}
}

data "aws_iam_policy_document" "sfn_state_machine_rekognition_detect_text" {
statement {
actions = [
"s3:GetObject",
"s3:GetObjectAttributes",
"s3:GetObjectVersion"
]
effect = "Allow"
resources = [
"${aws_s3_bucket.main.arn}/${aws_s3_object.images.key}*"
]
}

statement {
actions = [
"s3:GetBucketVersioning",
"s3:ListBucket"
]
effect = "Allow"
resources = [
"${aws_s3_bucket.main.arn}"
]
}

statement {
actions = [
"rekognition:DetectText"
]
effect = "Allow"
resources = [
"*"
]
}
}
15 changes: 15 additions & 0 deletions aws_iam_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,18 @@ resource "aws_iam_role" "sfn_state_machine_rekognition_detect_protective_equipme
workspace = terraform.workspace
}
}

resource "aws_iam_role" "sfn_state_machine_rekognition_detect_text" {
assume_role_policy = data.aws_iam_policy_document.assume_role_sfn_state_machine_rekognition_detect_text.json
name = "sfn-state-machine-rekognition-detect-text"
path = "/${local.organization}/"
tags = {
caller_identity_account_arn = data.aws_caller_identity.main.arn
caller_identity_account_id = data.aws_caller_identity.main.account_id
caller_identity_user_id = data.aws_caller_identity.main.user_id
canonical_user_id = data.aws_canonical_user_id.main.id
organization = local.organization
region = data.aws_region.main.name
workspace = terraform.workspace
}
}
5 changes: 5 additions & 0 deletions aws_iam_role_policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ resource "aws_iam_role_policy" "sfn_state_machine_rekognition_detect_protective_
policy = data.aws_iam_policy_document.sfn_state_machine_rekognition_detect_protective_equipment.json
role = aws_iam_role.sfn_state_machine_rekognition_detect_protective_equipment.id
}

resource "aws_iam_role_policy" "sfn_state_machine_rekognition_detect_text" {
policy = data.aws_iam_policy_document.sfn_state_machine_rekognition_detect_text.json
role = aws_iam_role.sfn_state_machine_rekognition_detect_text.id
}
18 changes: 18 additions & 0 deletions aws_sfn_state_machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,21 @@ resource "aws_sfn_state_machine" "rekognition_detect_protective_equipment" {
workspace = terraform.workspace
}
}

resource "aws_sfn_state_machine" "rekognition_detect_text" {
definition = templatefile("./state_machine/RekognitionDetectText.json", {})
name = "rekognition-detect-text"
role_arn = aws_iam_role.sfn_state_machine_rekognition_detect_text.arn
tags = {
bucket = aws_s3_bucket.main.bucket
bucket_key = aws_s3_object.images.key
caller_identity_account_arn = data.aws_caller_identity.main.arn
caller_identity_account_id = data.aws_caller_identity.main.account_id
caller_identity_user_id = data.aws_caller_identity.main.user_id
canonical_user_id = data.aws_canonical_user_id.main.id
organization = local.organization
rekognition = "DetectText"
region = data.aws_region.main.name
workspace = terraform.workspace
}
}
Loading
Loading