Skip to content

Commit

Permalink
feat: Add github secrets to terraform files
Browse files Browse the repository at this point in the history
  • Loading branch information
djnovin committed Jan 13, 2025
1 parent ef2b7df commit 35151fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ jobs:

- name: Terraform Plan
id: plan
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: terraform plan -no-color -out=tfplan

- name: Terraform Apply
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: terraform apply -auto-approve tfplan
11 changes: 8 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ variable "IMAGE_TAG" {
default = "latest"
}

variable "DATABASE_URL" {
description = "The connection string for the database"
type = string
sensitive = true
}

# Tags for resources
locals {
tags = {
Expand Down Expand Up @@ -100,9 +106,8 @@ resource "aws_lambda_function" "lambda" {

environment {
variables = {
NODE_ENV = "production"
BASE_URL = "https://shortener.example.com"
AWS_REGION = var.AWS_REGION
NODE_ENV = "production"
DATABASE_URL = var.DATABASE_URL
}
}

Expand Down

0 comments on commit 35151fa

Please sign in to comment.