injeolmi

command module
v0.0.0-...-792ff4d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 10 Imported by: 0

README

What is Injeolmi?

Injeolmi is AWS Lambda function for running terraform task through Gitlab CI/CD Pipeline.

It is very inspired by atlantis. The difference is that the terraform-cli is performed on the Gitlab-Pipeline.

arch

Service architecture

A series of AWS resources for deploying injeolmi can be build with terraform in /infra.

arch

App architecture

App is running on AWS Lambda. It works as follows

  • Parse info from the webhook-events.
  • Load gitlab-token from env(GITLAB_TOKEN) and webhook-secret from env(GITLAB_WEBHOOK_SECRET).
  • Validate webbhook-secret.
  • Analyze comments and run the action according to the result.

How to use

  1. generate gitlab-token and random string for webhook-secret.

  2. Add .gitlab-ci.yml in your gitlab project.

variables:
  CHDIR: "%NEED_TO_INPUT%"

workflow:
  rules:
    - if: $CHDIR == "%NEED_TO_INPUT%"
      when: never
    - if: $CI_PIPELINE_SOURCE == "api" || $CI_PIPELINE_SOURCE == "web"
      when: always

image:
  name: hashicorp/terraform:light
  entrypoint:
    - '/usr/bin/env'
    - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

stages:
  - plan
  - apply

terraform plan:
  stage: plan
  script:
    - cd $CHDIR
    - terraform init 
    - terraform plan -out "planfile"
  artifacts:
    paths:
      - $CHDIR/planfile

terraform apply:
  stage: apply
  script:
    - cd $CHDIR
    - terraform init
    - terraform apply "planfile"
  when: manual
  dependencies:
    - terraform plan
  1. Deploy AWS resource
$ ./loca-build.sh
$ cd ./infra
$ terraform init 
$ terraform plan -out "plan" # <-- need to input gitlab_token, webhook_secret
$ terraform apply "plan"
  1. Setup gitlab webhook (Settings > Webhooks)
  • In URL, input apigateway_invoke_url value from terraform output.
  • In Secret token, inputwebhook-secret value.
  • In Trigger, check Comments.
  • Run test

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL