Skip to content

Commit

Permalink
Fix release Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsuya28 committed Dec 31, 2023
1 parent c05fc68 commit f6058c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Build
run: |
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o aws-cost-report main.go
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} CGO_ENABLED=0 go build -o aws-cost-report main.go
- name: Zip
run: zip ${{ matrix.os }}-${{ matrix.arch }}-aws-cost-report.zip aws-cost-report
Expand Down
28 changes: 24 additions & 4 deletions module/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,34 @@ variable "schedule_expression" {
default = "cron(0 0 * * ? *)"
}
variable "build_version" {
default = "v0.0.0"
default = "v0.1.0"
}

locals {
lambda_zip_file = format("%s/.terraform/%s.zip", path.root, var.build_version)
}

data "github_release" "this" {
owner = "tetsuya28"
repository = "aws-cost-report"
retrieve_by = "tag"
release_tag = var.build_version
}

resource "null_resource" "this" {
triggers = {
timestamp = timestamp()
}
provisioner "local-exec" {
command = "wget -O ${local.lambda_zip_file} ${data.github_release.this.assets[2].browser_download_url}"
}
}

resource "aws_lambda_function" "this" {
function_name = var.name
s3_bucket = "tetsuya28-aws-cost-report"
s3_key = "${var.build_version}/main.zip"
runtime = "go1.x"
handler = "main"
handler = "aws-cost-report"
filename = local.lambda_zip_file
memory_size = 128
timeout = 10
role = aws_iam_role.this.arn
Expand All @@ -23,6 +42,7 @@ resource "aws_lambda_function" "this" {
"SLACK_CHANNEL" = var.slack_channel
}
}
depends_on = [null_resource.this]
}

resource "aws_cloudwatch_log_group" "this" {
Expand Down

0 comments on commit f6058c1

Please sign in to comment.