-
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.
Merge pull request #52 from bcgov/ssoteam-2010
Chore: terraform loki
- Loading branch information
Showing
33 changed files
with
1,490 additions
and
188 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,49 @@ | ||
name: Create and publish SSO Grafana | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
paths: | ||
- grafana-config/* | ||
- .github/workflows/publish-grafana-image.yaml | ||
|
||
env: | ||
GITHUB_REGISTRY: ghcr.io | ||
IMAGE_NAME: bcgov/sso-loki | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: hmarr/debug-action@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Log in to the GitHub Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.GITHUB_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=sha,format=long | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: grafana-config | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,94 @@ | ||
name: Terraform | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- dev | ||
- main | ||
paths: | ||
- terraform-ecs/** | ||
- loki-authorizer/** | ||
- .github/** | ||
|
||
env: | ||
TF_VERSION: 1.9.7 | ||
|
||
jobs: | ||
terraform: | ||
permissions: write-all | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: hmarr/debug-action@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install asdf | ||
uses: asdf-vm/actions/setup@v3 | ||
|
||
- name: Cache tools | ||
uses: actions/cache@v4 | ||
with: | ||
path: /home/runner/.asdf | ||
key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} | ||
|
||
- name: Install required tools | ||
run: | | ||
cat .tool-versions | cut -f 1 -d ' ' | xargs -n 1 asdf plugin-add || true | ||
asdf plugin-update --all | ||
asdf install | ||
asdf reshim | ||
shell: bash | ||
|
||
- name: Set env to development | ||
if: (github.ref == 'refs/heads/dev' && github.event_name == 'push') | ||
run: | | ||
cat >> $GITHUB_ENV <<EOF | ||
TERRAFORM_DEPLOY_ROLE_ARN=${{ secrets.TERRAFORM_DEPLOY_ROLE_ARN_DEV }} | ||
LOKI_AUTH_TOKEN=${{ secrets.LOKI_AUTH_TOKEN_DEV }} | ||
LOKI_BUCKET_NAME=${{ vars.LOKI_BUCKET_NAME_DEV }} | ||
S3_BACKEND_NAME=${{vars.S3_BACKEND_NAME_DEV}} | ||
LOKI_TAG=dev | ||
EOF | ||
- name: Set env to production | ||
if: (github.ref == 'refs/heads/main' && github.event_name == 'push') | ||
run: | | ||
cat >> $GITHUB_ENV <<EOF | ||
TERRAFORM_DEPLOY_ROLE_ARN=${{ secrets.TERRAFORM_DEPLOY_ROLE_ARN_PROD }} | ||
LOKI_AUTH_TOKEN=${{ secrets.LOKI_AUTH_TOKEN_PROD }} | ||
LOKI_BUCKET_NAME=${{ vars.LOKI_BUCKET_NAME_PROD }} | ||
S3_BACKEND_NAME=${{vars.S3_BACKEND_NAME_PROD}} | ||
LOKI_TAG=prod | ||
EOF | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ env.TERRAFORM_DEPLOY_ROLE_ARN }} | ||
aws-region: ca-central-1 | ||
|
||
- name: Build Lambdas | ||
working-directory: ./loki-authorizer | ||
run: make build | ||
|
||
- name: Terraform Init | ||
working-directory: ./terraform-ecs | ||
run: | | ||
cat <<EOF > backend.hcl | ||
bucket = "${{ env.S3_BACKEND_NAME }}" | ||
key = "tf-state" | ||
region = "ca-central-1" | ||
EOF | ||
terraform init -backend-config=backend.hcl | ||
- name: Terraform Plan | ||
run: terraform plan -var "auth_secret=${{env.LOKI_AUTH_TOKEN}}" -var "bucket_name=${{ env.LOKI_BUCKET_NAME }}" -var "loki_tag=${{env.LOKI_TAG}}" -no-color | ||
working-directory: ./terraform-ecs | ||
|
||
- name: Terraform Apply | ||
run: terraform apply -var "auth_secret=${{env.LOKI_AUTH_TOKEN}}" -var "bucket_name=${{ env.LOKI_BUCKET_NAME }}" -var "loki_tag=${{env.LOKI_TAG}}" -auto-approve | ||
working-directory: ./terraform-ecs |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
helm/**/charts | ||
get-pip.py | ||
**/.env | ||
node_modules | ||
.terraform | ||
*.tfstate | ||
*.tfstate.backup | ||
loki-authorizer.zip |
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ postgres 14.1 | |
golang 1.21.0 | ||
helm 3.10.2 | ||
loki-logcli 2.9.2 | ||
terraform 1.9.7 |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.