mirror of https://github.com/ivanch/ivanch.me.git
couple of fixes
This commit is contained in:
parent
0a9c891d9a
commit
10db94eeef
|
@ -35,6 +35,3 @@ jobs:
|
||||||
remote_port: ${{ secrets.DEPLOY_PORT }}
|
remote_port: ${{ secrets.DEPLOY_PORT }}
|
||||||
remote_user: ${{ secrets.DEPLOY_USER }}
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
||||||
remote_key: ${{ secrets.DEPLOY_KEY }}
|
remote_key: ${{ secrets.DEPLOY_KEY }}
|
||||||
|
|
||||||
- name: Deployed
|
|
||||||
run: echo Deployed to ${{ secrets.DEPLOY_HOST }}!
|
|
|
@ -5,9 +5,9 @@ draft: false
|
||||||
summary: "How to create API Gateway endpoints with Terraform."
|
summary: "How to create API Gateway endpoints with Terraform."
|
||||||
---
|
---
|
||||||
|
|
||||||
Right when we first started to use Terraform, we had a lot of problems with the API Gateway. We had to create a lot of resources, manage 1,000s of lines of `.tf` files, and it was a lot of work that required more attention and time, things that are critical in software development as we all know.
|
Right when we first started to use the AWS API Gateway, one of the things that did bother us was the fact that we had to manage lot of resources, spread into 1,000s of lines of a couple of Terraform files, and it was a lot of work that required attention and time, things that are critical in software development as we all know.
|
||||||
|
|
||||||
So we decided to create a module to help us with this. Big thanks to [Stephano](https://www.linkedin.com/in/stephano-macedo/) who helped me with this!
|
So we decided to create a module to help us with this. Big thanks to [Stephano](https://www.linkedin.com/in/stephano-macedo/) who helped me a lot!
|
||||||
|
|
||||||
## Before
|
## Before
|
||||||
Basically, when we are developing a new API, we need to create a lot of resources in the API Gateway. We need to create a new resource, a new method and a new integration, and therefore connecting all of them using their respectives IDs.
|
Basically, when we are developing a new API, we need to create a lot of resources in the API Gateway. We need to create a new resource, a new method and a new integration, and therefore connecting all of them using their respectives IDs.
|
||||||
|
@ -54,12 +54,11 @@ resource "aws_api_gateway_integration" "api_users_all" {
|
||||||
|
|
||||||
Obviously there is more code to that, but this is the main part of it and that's what we will be using in the module.
|
Obviously there is more code to that, but this is the main part of it and that's what we will be using in the module.
|
||||||
|
|
||||||
## After (Creating a module)
|
## Creating a module
|
||||||
|
Now we can create a module to help us. We can start by creating a separate folder which will be our module, let's call it `terraform/modules/api`, inside of it there will be a couple of files:
|
||||||
Now, we can create a module to help us with this. We can start by summarizing what we had into a separate folder. We will call this folder `terraform/modules/api`, inside it there will be a couple of files:
|
|
||||||
|
|
||||||
### variables.tf
|
### variables.tf
|
||||||
Here we will define the variables that we will use in the module, what will come from the outside.
|
Here we will define the variables that we will use in the module, what will come from the outside. Note that here it's just the essencial, you will add more things as you need.
|
||||||
```terraform
|
```terraform
|
||||||
# This is the parent resource ID in case we have something like /users/all/prune
|
# This is the parent resource ID in case we have something like /users/all/prune
|
||||||
variable "parent_id" {
|
variable "parent_id" {
|
||||||
|
@ -109,7 +108,7 @@ variable "authorization" {
|
||||||
```
|
```
|
||||||
|
|
||||||
### outputs.tf
|
### outputs.tf
|
||||||
This file is needed for at least one important variable, which is the `resource_id`. That's needed if we have some endpoint like `/users/all/prune`.
|
This file is needed for at least one important variable, which is the `resource_id`. That's needed if we have some endpoint like `/users/all/prune` which needs a `parent_id`.
|
||||||
```terraform
|
```terraform
|
||||||
output "resource_id" {
|
output "resource_id" {
|
||||||
value = local.resource_id
|
value = local.resource_id
|
||||||
|
@ -184,7 +183,6 @@ resource "aws_api_gateway_integration" "api_integration" {
|
||||||
"integration.request.path.${local.path_variable}" = "method.request.path.${local.path_variable}"
|
"integration.request.path.${local.path_variable}" = "method.request.path.${local.path_variable}"
|
||||||
} : {})
|
} : {})
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using the module
|
## Using the module
|
||||||
|
|
|
@ -26,7 +26,7 @@ Litty bitty apocalyptic.
|
||||||
* [Transmission](https://hub.docker.com/r/linuxserver/transmission/) - Torrent client with a web interface.
|
* [Transmission](https://hub.docker.com/r/linuxserver/transmission/) - Torrent client with a web interface.
|
||||||
* [Sonarr](https://hub.docker.com/r/linuxserver/sonarr/) - TV shows management (Torrent integration).
|
* [Sonarr](https://hub.docker.com/r/linuxserver/sonarr/) - TV shows management (Torrent integration).
|
||||||
* [Radarr](https://hub.docker.com/r/linuxserver/radarr/) - Movies management (Torrent integration).
|
* [Radarr](https://hub.docker.com/r/linuxserver/radarr/) - Movies management (Torrent integration).
|
||||||
* [Jekyll](https://hub.docker.com/r/jekyll/jekyll/) - Homemade Netflix.
|
* [Jellyfin](https://hub.docker.com/r/linuxserver/jellyfin/) - Homemade Netflix.
|
||||||
|
|
||||||
## Game server
|
## Game server
|
||||||
* [Minecraft Server](https://hub.docker.com/r/itzg/minecraft-server/) - The name says by itself².
|
* [Minecraft Server](https://hub.docker.com/r/itzg/minecraft-server/) - The name says by itself².
|
Loading…
Reference in New Issue