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
58 lines (48 loc) · 1.77 KB
/
s3.tf
File metadata and controls
58 lines (48 loc) · 1.77 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
# ============================================================================
# S3 Bucket for Agent Source Code (CDK Asset Equivalent)
# ============================================================================
resource "aws_s3_bucket" "agent_source" {
bucket_prefix = "${var.stack_name}-agent-source-"
force_destroy = true
tags = {
Name = "${var.stack_name}-agent-source"
Purpose = "Store agent source code for CodeBuild"
}
}
# Block public access
resource "aws_s3_bucket_public_access_block" "agent_source" {
bucket = aws_s3_bucket.agent_source.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
# Enable versioning for source code tracking
resource "aws_s3_bucket_versioning" "agent_source" {
bucket = aws_s3_bucket.agent_source.id
versioning_configuration {
status = "Enabled"
}
}
# ============================================================================
# Archive and Upload Agent Source Code
# ============================================================================
# Archive agent-code/ directory
# This automatically detects ALL files including new ones
data "archive_file" "agent_source" {
type = "zip"
source_dir = "${path.module}/agent-code"
output_path = "${path.module}/.terraform/agent-code.zip"
}
# Upload to S3 (re-uploads when MD5 changes)
resource "aws_s3_object" "agent_source" {
bucket = aws_s3_bucket.agent_source.id
key = "agent-code-${data.archive_file.agent_source.output_md5}.zip"
source = data.archive_file.agent_source.output_path
etag = data.archive_file.agent_source.output_md5
tags = {
Name = "agent-source-code"
MD5 = data.archive_file.agent_source.output_md5
Timestamp = timestamp()
}
}