Skip to content

Commit

Permalink
Deploy wheel file in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kseebaldt committed Sep 19, 2022
1 parent 9bdf6d4 commit f18cc83
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ jobs:
run: poetry install
- name: Run tests
run: bin/test
- name: Build wheel
run: poetry build -f wheel
- uses: jakejarvis/s3-sync-action@master
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: 'dist'
DEST_DIR: 'dist'
49 changes: 49 additions & 0 deletions tf/modules/deploy/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
terraform {
required_version = "~> 1.2.9"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.30.0"
}
github = {
source = "integrations/github"
version = "~> 4.0"
}
}
}

resource "aws_iam_user" "deploy_user" {
name = "${var.app_prefix}-deploy"

}

resource "aws_iam_policy" "deploy_policy" {
name = "${var.app_prefix}-deploy"
description = "${var.app_prefix} Deploy Policy"
policy = templatefile("${path.module}/policies/deploy_policy.json.tpl", {
data_bucket = var.data_bucket
})
}

resource "aws_iam_access_key" "deploy_user_access_key" {
user = aws_iam_user.deploy_user.name
}

resource "github_actions_secret" "deploy_access_key_id" {
repository = var.github_repository
secret_name = "AWS_ACCESS_KEY_ID"
plaintext_value = aws_iam_access_key.deploy_user_access_key.id
}

resource "github_actions_secret" "deploy_secret_access_key" {
repository = var.github_repository
secret_name = "AWS_SECRET_ACCESS_KEY"
plaintext_value = aws_iam_access_key.deploy_user_access_key.secret
}

resource "github_actions_secret" "deploy_bucket" {
repository = var.github_repository
secret_name = "AWS_S3_BUCKET"
plaintext_value = var.data_bucket
}
17 changes: 17 additions & 0 deletions tf/modules/deploy/policies/deploy_policy.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::${data_bucket}/dist/*"
]
}
]
}
11 changes: 11 additions & 0 deletions tf/modules/deploy/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "app_prefix" {
type = string
}

variable "data_bucket" {
type = string
}

variable "github_repository" {
type = string
}
8 changes: 8 additions & 0 deletions tf/test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ module "glue" {
data_bucket = module.buckets.data_bucket
}

module "deploy" {
source = "../modules/deploy"

app_prefix = "kurtis-test"
data_bucket = module.buckets.data_bucket
github_repository = "sample_glue_pipelines"
}

module "pipelines" {
source = "../pipelines"

Expand Down

0 comments on commit f18cc83

Please sign in to comment.