Skip to content

Commit 1b5b793

Browse files
committed
Add terraform lock file and oidc configuration
1 parent 7a108fa commit 1b5b793

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/.terraform.lock.hcl

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

.github/workflows/oidc.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
terraform {
2+
backend "local" {
3+
path = ".terraform/oidc/terraform.tfstate"
4+
}
5+
}
6+
7+
provider "aws" {
8+
region = "ap-northeast-1"
9+
}
10+
11+
data "aws_caller_identity" "current" {}
12+
13+
data "aws_iam_openid_connect_provider" "github_actions" {
14+
arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/token.actions.githubusercontent.com"
15+
}
16+
17+
resource "aws_iam_role" "github_actions" {
18+
name = "github-actions-docker-selenium-lambda"
19+
assume_role_policy = jsonencode({
20+
Version = "2012-10-17"
21+
Statement = [{
22+
Effect = "Allow"
23+
Action = "sts:AssumeRoleWithWebIdentity"
24+
Principal = {
25+
Federated = data.aws_iam_openid_connect_provider.github_actions.arn
26+
}
27+
Condition = {
28+
StringLike = {
29+
"token.actions.githubusercontent.com:sub" = [
30+
"repo:umihico/docker-selenium-lambda:*"
31+
]
32+
}
33+
}
34+
}]
35+
})
36+
managed_policy_arns = ["arn:aws:iam::aws:policy/AdministratorAccess"]
37+
}
38+
39+
output "aws_iam_openid_connect_provider" {
40+
value = data.aws_iam_openid_connect_provider.github_actions.arn
41+
}
42+
43+
output "aws_iam_role" {
44+
# gh secret set AWS_ROLE_ARN
45+
value = aws_iam_role.github_actions.arn
46+
}

0 commit comments

Comments
 (0)