Skip to content

Commit 4e5f482

Browse files
committed
import sponsor-app//tfmod
1 parent 0b3e0d2 commit 4e5f482

File tree

9 files changed

+356
-0
lines changed

9 files changed

+356
-0
lines changed

tf/sponsor-app/.mairu.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"server": "https://amc.rubykaigi.net/api/remote/",
3+
"role": "arn:aws:iam::005216166247:role/OrgzAdmin"
4+
}

tf/sponsor-app/.terraform.lock.hcl

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tf/sponsor-app/acm.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data "aws_acm_certificate" "use1-sponsorships-rk-o" {
2+
provider = aws.use1
3+
domain = "sponsorships.rubykaigi.org"
4+
most_recent = true
5+
}

tf/sponsor-app/aws.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
data "aws_caller_identity" "current" {}
2+
3+
locals {
4+
aws_account_id = "005216166247"
5+
}
6+
7+
provider "aws" {
8+
region = "us-west-2"
9+
allowed_account_ids = [local.aws_account_id]
10+
default_tags {
11+
tags = {
12+
Project = "sponsor-app"
13+
}
14+
}
15+
}
16+
17+
provider "aws" {
18+
alias = "use1"
19+
region = "us-east-1"
20+
allowed_account_ids = [local.aws_account_id]
21+
default_tags {
22+
tags = {
23+
Project = "sponsor-app"
24+
}
25+
}
26+
}
27+
28+
provider "aws" {
29+
alias = "apne1"
30+
region = "ap-northeast-1"
31+
allowed_account_ids = [local.aws_account_id]
32+
default_tags {
33+
tags = {
34+
Project = "sponsor-app"
35+
}
36+
}
37+
}

tf/sponsor-app/backend.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
backend "s3" {
3+
bucket = "rk-infra"
4+
workspace_key_prefix = "terraform"
5+
key = "terraform/sponsor-app.tfstate"
6+
region = "ap-northeast-1"
7+
use_lockfile = true
8+
}
9+
}

tf/sponsor-app/dev.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module "dev" {
2+
source = "../../../sponsor-app/tfmod"
3+
4+
providers = {
5+
aws = aws
6+
aws.use1 = aws.use1
7+
aws.apne1 = aws.apne1
8+
}
9+
10+
environment = "dev"
11+
service_name = "sponsor-app-dev"
12+
sqs_name_suffix = "dev"
13+
iam_role_prefix = "SponsorAppDev"
14+
iam_apprunner_access_name = "AppraSponsorAppDev"
15+
16+
s3_bucket_name = "rk-sponsorship-files-dev"
17+
s3_cors_origins = [
18+
"http://localhost:13000",
19+
"http://localhost:13010",
20+
"http://localhost:3000",
21+
"https://amc.rubykaigi.net",
22+
]
23+
24+
enable_cloudfront = false
25+
enable_sqs = false
26+
enable_apprunner = false
27+
enable_amc_oidc = true
28+
enable_shared_resources = false
29+
30+
github_actions_sub = "repo:ruby-no-kai/sponsor-app:ref:refs/heads/master"
31+
}

tf/sponsor-app/moved.tf

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# State migration from sponsor-app/tf to module-based structure
2+
3+
# ECR (shared, goes to prd module with [0])
4+
moved {
5+
from = aws_ecr_repository.app
6+
to = module.prd.aws_ecr_repository.app[0]
7+
}
8+
9+
moved {
10+
from = aws_ecr_lifecycle_policy.app
11+
to = module.prd.aws_ecr_lifecycle_policy.app[0]
12+
}
13+
14+
# S3 - Production bucket and configs
15+
moved {
16+
from = aws_s3_bucket.files-prd
17+
to = module.prd.aws_s3_bucket.files
18+
}
19+
20+
moved {
21+
from = aws_s3_bucket_public_access_block.files["prd"]
22+
to = module.prd.aws_s3_bucket_public_access_block.files
23+
}
24+
25+
moved {
26+
from = aws_s3_bucket_versioning.files["prd"]
27+
to = module.prd.aws_s3_bucket_versioning.files
28+
}
29+
30+
moved {
31+
from = aws_s3_bucket_lifecycle_configuration.files["prd"]
32+
to = module.prd.aws_s3_bucket_lifecycle_configuration.files
33+
}
34+
35+
moved {
36+
from = aws_s3_bucket_accelerate_configuration.files["prd"]
37+
to = module.prd.aws_s3_bucket_accelerate_configuration.files
38+
}
39+
40+
moved {
41+
from = aws_s3_bucket_cors_configuration.files-prd
42+
to = module.prd.aws_s3_bucket_cors_configuration.files
43+
}
44+
45+
# S3 - Development bucket and configs
46+
moved {
47+
from = aws_s3_bucket.files-dev
48+
to = module.dev.aws_s3_bucket.files
49+
}
50+
51+
moved {
52+
from = aws_s3_bucket_public_access_block.files["dev"]
53+
to = module.dev.aws_s3_bucket_public_access_block.files
54+
}
55+
56+
moved {
57+
from = aws_s3_bucket_versioning.files["dev"]
58+
to = module.dev.aws_s3_bucket_versioning.files
59+
}
60+
61+
moved {
62+
from = aws_s3_bucket_lifecycle_configuration.files["dev"]
63+
to = module.dev.aws_s3_bucket_lifecycle_configuration.files
64+
}
65+
66+
moved {
67+
from = aws_s3_bucket_accelerate_configuration.files["dev"]
68+
to = module.dev.aws_s3_bucket_accelerate_configuration.files
69+
}
70+
71+
moved {
72+
from = aws_s3_bucket_cors_configuration.files-dev
73+
to = module.dev.aws_s3_bucket_cors_configuration.files
74+
}
75+
76+
# SQS (production only)
77+
moved {
78+
from = aws_sqs_queue.activejob-prd
79+
to = module.prd.aws_sqs_queue.activejob[0]
80+
}
81+
82+
moved {
83+
from = aws_sqs_queue.activejob-dlq-prd
84+
to = module.prd.aws_sqs_queue.activejob-dlq[0]
85+
}
86+
87+
# App Runner (production only)
88+
moved {
89+
from = aws_apprunner_service.prd
90+
to = module.prd.aws_apprunner_service.prd[0]
91+
}
92+
93+
# CloudFront (production only)
94+
moved {
95+
from = aws_cloudfront_distribution.prd
96+
to = module.prd.aws_cloudfront_distribution.prd[0]
97+
}
98+
99+
# CloudWatch Log Groups (shared, goes to prd module with [0])
100+
moved {
101+
from = aws_cloudwatch_log_group.worker
102+
to = module.prd.aws_cloudwatch_log_group.worker[0]
103+
}
104+
105+
moved {
106+
from = aws_cloudwatch_log_group.batch
107+
to = module.prd.aws_cloudwatch_log_group.batch[0]
108+
}
109+
110+
# IAM - Production App Role
111+
moved {
112+
from = aws_iam_role.SponsorApp
113+
to = module.prd.aws_iam_role.SponsorApp
114+
}
115+
116+
moved {
117+
from = aws_iam_role_policy.SponsorApp
118+
to = module.prd.aws_iam_role_policy.SponsorApp
119+
}
120+
121+
# IAM - Development App Role
122+
moved {
123+
from = aws_iam_role.SponsorAppDev
124+
to = module.dev.aws_iam_role.SponsorApp
125+
}
126+
127+
moved {
128+
from = aws_iam_role_policy.SponsorAppDev
129+
to = module.dev.aws_iam_role_policy.SponsorApp
130+
}
131+
132+
# IAM - Production User Role (S3 uploads)
133+
moved {
134+
from = aws_iam_role.SponsorAppUser
135+
to = module.prd.aws_iam_role.SponsorAppUser
136+
}
137+
138+
moved {
139+
from = aws_iam_role_policy.SponsorAppUser
140+
to = module.prd.aws_iam_role_policy.SponsorAppUser
141+
}
142+
143+
# IAM - Development User Role (S3 uploads)
144+
moved {
145+
from = aws_iam_role.SponsorAppDevUser
146+
to = module.dev.aws_iam_role.SponsorAppUser
147+
}
148+
149+
moved {
150+
from = aws_iam_role_policy.SponsorAppDevUser
151+
to = module.dev.aws_iam_role_policy.SponsorAppUser
152+
}
153+
154+
# IAM - App Runner Access Role (ECR pull)
155+
moved {
156+
from = aws_iam_role.app-runner-access
157+
to = module.prd.aws_iam_role.app-runner-access[0]
158+
}
159+
160+
moved {
161+
from = aws_iam_role_policy.app-runner-access
162+
to = module.prd.aws_iam_role_policy.app-runner-access[0]
163+
}
164+
165+
# IAM - ECS Task Execution Role (shared, goes to prd module with [0])
166+
moved {
167+
from = aws_iam_role.EcsExecSponsorApp
168+
to = module.prd.aws_iam_role.EcsExecSponsorApp[0]
169+
}
170+
171+
moved {
172+
from = aws_iam_role_policy.EcsExecSponsorApp
173+
to = module.prd.aws_iam_role_policy.EcsExecSponsorApp[0]
174+
}
175+
176+
# IAM - GitHub Actions Deployment Role (shared, goes to prd module with [0])
177+
moved {
178+
from = aws_iam_role.GhaSponsorDeploy
179+
to = module.prd.aws_iam_role.GhaSponsorDeploy[0]
180+
}
181+
182+
moved {
183+
from = aws_iam_role_policy.GhaSponsorDeploy
184+
to = module.prd.aws_iam_role_policy.GhaSponsorDeploy[0]
185+
}

tf/sponsor-app/prd.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module "prd" {
2+
source = "../../../sponsor-app/tfmod"
3+
4+
providers = {
5+
aws = aws
6+
aws.use1 = aws.use1
7+
aws.apne1 = aws.apne1
8+
}
9+
10+
environment = "production"
11+
service_name = "sponsor-app"
12+
sqs_name_suffix = "prd"
13+
iam_role_prefix = "SponsorApp"
14+
iam_apprunner_access_name = "AppraSponsorApp"
15+
16+
s3_bucket_name = "rk-sponsorship-files-prd"
17+
s3_cors_origins = ["https://sponsorships.rubykaigi.org"]
18+
19+
enable_cloudfront = true
20+
enable_sqs = true
21+
enable_apprunner = true
22+
enable_amc_oidc = false
23+
enable_shared_resources = true
24+
25+
app_domain = "sponsorships.rubykaigi.org"
26+
certificate_arn = data.aws_acm_certificate.use1-sponsorships-rk-o.arn
27+
cloudfront_log_bucket = "rk-aws-logs.s3.amazonaws.com"
28+
cloudfront_log_prefix = "cf/sponsorships.rubykaigi.org/"
29+
cloudfront_comment = "sponsor-app"
30+
31+
github_actions_sub = "repo:ruby-no-kai/sponsor-app:environment:production"
32+
}

tf/sponsor-app/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
}
6+
}
7+
required_version = ">= 0.13"
8+
}

0 commit comments

Comments
 (0)