forked from awslabs/amazon-bedrock-agentcore-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths3.tf
More file actions
109 lines (90 loc) · 3.38 KB
/
s3.tf
File metadata and controls
109 lines (90 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# ============================================================================
# S3 Buckets for Agent Source Code (CDK Asset Equivalent)
# ============================================================================
# Orchestrator Agent Source Bucket
resource "aws_s3_bucket" "orchestrator_source" {
bucket_prefix = "acma-orch-src-" # Shortened to fit 37 char limit
force_destroy = true
tags = {
Name = "${var.stack_name}-orchestrator-source"
Purpose = "Store Orchestrator agent source code for CodeBuild"
}
}
# Specialist Agent Source Bucket
resource "aws_s3_bucket" "specialist_source" {
bucket_prefix = "acma-spec-src-" # Shortened to fit 37 char limit
force_destroy = true
tags = {
Name = "${var.stack_name}-specialist-source"
Purpose = "Store Specialist agent source code for CodeBuild"
}
}
# Block public access - Orchestrator
resource "aws_s3_bucket_public_access_block" "orchestrator_source" {
bucket = aws_s3_bucket.orchestrator_source.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
# Block public access - Specialist
resource "aws_s3_bucket_public_access_block" "specialist_source" {
bucket = aws_s3_bucket.specialist_source.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
# Enable versioning - Orchestrator
resource "aws_s3_bucket_versioning" "orchestrator_source" {
bucket = aws_s3_bucket.orchestrator_source.id
versioning_configuration {
status = "Enabled"
}
}
# Enable versioning - Specialist
resource "aws_s3_bucket_versioning" "specialist_source" {
bucket = aws_s3_bucket.specialist_source.id
versioning_configuration {
status = "Enabled"
}
}
# ============================================================================
# Archive and Upload Agent Source Code
# ============================================================================
# Archive agent-orchestrator-code/ directory
data "archive_file" "orchestrator_source" {
type = "zip"
source_dir = "${path.module}/agent-orchestrator-code"
output_path = "${path.module}/.terraform/agent-orchestrator-code.zip"
}
# Archive agent-specialist-code/ directory
data "archive_file" "specialist_source" {
type = "zip"
source_dir = "${path.module}/agent-specialist-code"
output_path = "${path.module}/.terraform/agent-specialist-code.zip"
}
# Upload Orchestrator source to S3
resource "aws_s3_object" "orchestrator_source" {
bucket = aws_s3_bucket.orchestrator_source.id
key = "agent-orchestrator-code-${data.archive_file.orchestrator_source.output_md5}.zip"
source = data.archive_file.orchestrator_source.output_path
etag = data.archive_file.orchestrator_source.output_md5
tags = {
Name = "agent-orchestrator-source-code"
Agent = "Orchestrator"
MD5 = data.archive_file.orchestrator_source.output_md5
}
}
# Upload Specialist source to S3
resource "aws_s3_object" "specialist_source" {
bucket = aws_s3_bucket.specialist_source.id
key = "agent-specialist-code-${data.archive_file.specialist_source.output_md5}.zip"
source = data.archive_file.specialist_source.output_path
etag = data.archive_file.specialist_source.output_md5
tags = {
Name = "agent-specialist-source-code"
Agent = "Specialist"
MD5 = data.archive_file.specialist_source.output_md5
}
}