Skip to content

Commit

Permalink
lambda with custom domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Ujstor committed Jun 27, 2024
1 parent 1589898 commit d8165eb
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 707 deletions.
2 changes: 2 additions & 0 deletions .auto.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cloudflare_api_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
cloudflare_zone_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ override.tf.json
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
*.lock.hcl
.auto.tfvars

bootstrap
*.zip
Expand Down
28 changes: 6 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Portfolio Website

This static website is built with Go and Templ and deployed on AWS Lambda with Terraform.
This static website is built with Go and Templ, deployed on AWS Lambda with Terraform, and is accessible via a Cloudflare custom domain.

Complete website in singe binary.

Expand All @@ -11,35 +11,19 @@ First, build the binary for the Lambda function, which will later be zipped and
```bash
make build
```
On Cloudflare, create an API key that can write DNS records. Along with the specific Cloudflare zone ID for the domain, import the credentials into the .auto.tfvars file:

cd into aws-infra and run terraform apply:
Run terraform commands:

```bash
cd aws-infra
terraform init
terraform apply
```
Three main resources are created:

output will provide the URL to the website:
Lambda function, an API Gateway, a certificate in ACM, and an updated Cloudflare domain entry.

```bash
Outputs:

api_gateway_url = {
"value" = "https://dx90b08zwj.execute-api.us-east-1.amazonaws.com"
}
lambda_arn = {
"invoke_arn" = "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:795062932265:function:portfolio-web/invocations"
"lambda_arn" = "arn:aws:lambda:us-east-1:795062932265:function:portfolio-web"
"lambda_name" = "portfolio-web"
}
```

Two main resources are created:

Lambda function and API Gateway

![lambda](public/lambda.png)
![lambda](public/lambda-domain.png)

Destroy infrastructure:

Expand Down
48 changes: 0 additions & 48 deletions aws-infra/main.tf

This file was deleted.

201 changes: 0 additions & 201 deletions aws-infra/modules/API-gateway/LICENSE

This file was deleted.

77 changes: 0 additions & 77 deletions aws-infra/modules/API-gateway/main.tf

This file was deleted.

7 changes: 0 additions & 7 deletions aws-infra/modules/API-gateway/outputs.tf

This file was deleted.

Loading

0 comments on commit d8165eb

Please sign in to comment.