File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments