-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add infra folder and inital workflow
- Loading branch information
Showing
8 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build Infra | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- './infra/**' | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
run: | ||
name: run | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Install the terraform and terragrunt | ||
# - uses: alexellis/setup-arkade@v1 | ||
# - uses: alexellis/arkade-get@master | ||
# with: | ||
# terraform: latest | ||
# terragrunt: latest | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
aws-access-key-id: ${{ secrets.PERSONAL_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.PERSONAL_SECRET_ACCESS_KEY }} | ||
role-to-assume: ${{ vars.ROLE_TO_ASSUME }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
# Display IAM Identity | ||
- name: Display IAM Identity | ||
run: | | ||
aws sts get-caller-identity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
remote_state { | ||
backend = "s3" | ||
generate = { | ||
path = "backend.tf" | ||
if_exists = "overwrite_terragrunt" | ||
} | ||
config = { | ||
bucket = "keyless-workflow-demo" | ||
key = "keyless-workflow-demo/terraform.tfstate" | ||
|
||
region = "us-west-2" | ||
dynamodb_table = "tflocks" | ||
disable_bucket_update = true | ||
|
||
# Permissions thing | ||
skip_bucket_versioning = true | ||
|
||
encrypt = true | ||
} | ||
} | ||
|
||
terraform { | ||
source = ".//tf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "knowledgeshare_ecr_url" { | ||
value = aws_ecr_repository.knowledgeshare_ui_ecr.repository_url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4.0" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-west-2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "name" { | ||
type = string | ||
description = "The Repository Name" | ||
default = "keyless-workflow-demo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "aws_ecr_repository" "knowledgeshare_ui_ecr" { | ||
name = var.name | ||
image_tag_mutability = "MUTABLE" | ||
|
||
image_scanning_configuration { | ||
scan_on_push = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
resource "aws_ecs_cluster" "knowledgeshare_ui_ecs_cluster" { | ||
name = "knowledgeshare-demo" | ||
setting { | ||
name = "containerInsights" | ||
value = "enabled" | ||
} | ||
} | ||
|
||
resource "aws_ecs_task_definition" "knowledgeshare_ui_task" { | ||
family = "knowledgeshare-service" | ||
container_definitions = jsonencode([{ | ||
name = "knowledgeshare-ui" | ||
image = "${aws_ecr_repository.knowledgeshare_ui_ecr.repository_url}:latest" | ||
memory = 512 | ||
essential = true | ||
portMappings = [ | ||
{ | ||
containerPort = 8080 | ||
hostPort = 80 | ||
} | ||
] | ||
}]) | ||
} | ||
|
||
resource "aws_ecs_service" "knowledgeshare_ui_service" { | ||
name = "knowledgeshare_ui" | ||
cluster = aws_ecs_cluster.knowledgeshare_ui_ecs_cluster.id | ||
task_definition = aws_ecs_task_definition.knowledgeshare_ui_task.arn | ||
desired_count = 2 | ||
force_new_deployment = true | ||
# iam_role = aws_iam_role.foo.arn | ||
# depends_on = [aws_iam_role_policy.foo] | ||
|
||
} |