Skip to content

Commit 9847d2c

Browse files
Loquacityzsetajacobprall
authored
Update tutorials for more inclusive language (github#558)
* s/master/main * Update timescaledb/tutorials/aws-lambda/continuous-deployment.md Co-authored-by: Attila Tóth <hello@attilatoth.dev> Co-authored-by: Attila Tóth <hello@attilatoth.dev> Co-authored-by: Jacob Prall <prall.jacob@gmail.com>
1 parent 58f1ee4 commit 9847d2c

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

timescaledb/tutorials/aws-lambda/continuous-deployment.md

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# Lambda continuous deployment with GitHub actions
2-
This tutorial builds a continuous deployment (CD) pipeline between GitHub and AWS Lambda using GitHub actions.
2+
This tutorial builds a continuous deployment (CD) pipeline between GitHub and
3+
AWS Lambda using GitHub actions.
34

4-
Packaging and deploying your function and its dependencies with AWS Lambda can sometimes be a tedious job.
5-
Especially if you also want to use a source code management platform like GitHub to develop your code before pushing
6-
it to AWS Lambda.
5+
Packaging and deploying your function and its dependencies with AWS Lambda can
6+
sometimes be a tedious job. Especially if you also want to use a source code
7+
management platform like GitHub to develop your code before pushing it to AWS
8+
Lambda.
79

8-
You can use GitHub actions to set up automatic deployment for AWS Lambda from a Github repository.
9-
You need to push a commit to the main or master branch of your repository, then let GitHub actions create the deployment
10-
package, and deploy your code to AWS Lambda.
10+
You can use GitHub actions to set up automatic deployment for AWS Lambda from a
11+
Github repository. You need to push a commit to the `main` or `master` branch of
12+
your repository, then let GitHub actions create the deployment package, and
13+
deploy your code to AWS Lambda.
1114

1215
## Prerequisites
1316
* Git ([installation options here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git))
@@ -44,22 +47,22 @@ Now you can create a new GitHub repository which contains the function code.
4447
import psycopg2
4548
import psycopg2.extras
4649
import os
47-
50+
4851
def lambda_handler(event, context):
4952
db_name = os.environ['DB_NAME']
5053
db_user = os.environ['DB_USER']
5154
db_host = os.environ['DB_HOST']
5255
db_port = os.environ['DB_PORT']
5356
db_pass = os.environ['DB_PASS']
54-
57+
5558
conn = psycopg2.connect(user=db_user, database=db_name, host=db_host,
5659
password=db_pass, port=db_port)
57-
60+
5861
sql = "SELECT * FROM stocks_intraday ORDER BY time DESC LIMIT 10"
5962
cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
6063
cursor.execute(sql)
6164
result = cursor.fetchall()
62-
65+
6366
return {
6467
'statusCode': 200,
6568
'body': json.dumps(list_of_dicts, default=str),
@@ -73,21 +76,21 @@ Now you can create a new GitHub repository which contains the function code.
7376
git init
7477
git add function.py
7578
git commit -m "Initial commit: add Lambda function"
76-
git branch -M master
79+
git branch -M main
7780
git remote add origin <YOUR_GITHUB_PROJECT_URL.git>
78-
git push -u origin master
81+
git push -u origin main
7982
```
8083
81-
At this point, you have a GitHub repository with just the Lambda function in it. Now you can connect this repository
84+
At this point, you have a GitHub repository with just the Lambda function in it. Now you can connect this repository
8285
to the AWS Lambda function.
8386
8487
## Connect GitHub and AWS Lambda
8588
8689
Let's connect the Github repository AWS Lambda using Github actions.
8790

8891
### Procedure: Adding your AWS credentials to the repository
89-
You need to add your AWS credentials to the repository so it will have permission to connect to Lambda.
90-
You can do this by adding [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets)
92+
You need to add your AWS credentials to the repository so it will have permission to connect to Lambda.
93+
You can do this by adding [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets)
9194
using the GitHub CLI.
9295

9396
1. Authenticate with GitHub:
@@ -96,26 +99,26 @@ using the GitHub CLI.
9699
```
97100
This prompts you to choose which account you want to log into using either your password or GitHub
98101
authentication token.
99-
1. Add AWS credentials as GitHub secrets.
100-
By using GitHub secrets, your credentials are encrypted and cannot be seen
101-
publicly. Use the `gh secret set` command to upload your AWS credentials one by one
102+
1. Add AWS credentials as GitHub secrets.
103+
By using GitHub secrets, your credentials are encrypted and cannot be seen
104+
publicly. Use the `gh secret set` command to upload your AWS credentials one by one
102105
(you'll be prompted to paste the values for each one):
103-
106+
104107
AWS_ACCESS_KEY_ID:
105108
```bash
106109
gh secret set AWS_ACCESS_KEY_ID
107110
```
108-
111+
109112
AWS_SECRET_ACCESS_KEY:
110113
```bash
111114
gh secret set AWS_SECRET_ACCESS_KEY
112115
```
113-
116+
114117
AWS_REGION:
115118
```bash
116119
gh secret set AWS_REGION
117120
```
118-
121+
119122
1. To make sure your credentials have been uploaded correctly, you can list the available GitHub secrets:
120123
```bash
121124
gh secret list
@@ -134,7 +137,7 @@ to auto-deploy to AWS Lambda.
134137
```bash
135138
touch .github/workflows/main.yml
136139
```
137-
140+
138141
1. Add this content to the file:
139142
```yml
140143
name: deploy to lambda
@@ -143,9 +146,9 @@ to auto-deploy to AWS Lambda.
143146
# but only for the main branch
144147
push:
145148
branches:
146-
- master
149+
- main
147150
jobs:
148-
151+
149152
deploy_source:
150153
name: deploy lambda from source
151154
runs-on: ubuntu-latest
@@ -161,11 +164,11 @@ to auto-deploy to AWS Lambda.
161164
function_name: lambda-cd
162165
source: function.py
163166
```
164-
This configuration will make sure to deploy the code to Lambda when there's a new push to the master branch.
167+
This configuration will make sure to deploy the code to Lambda when there's a new push to the main branch.
165168

166-
As you can also see in the YAML file, the AWS credentials are accessed using the `${{ secrets.AWS_ACCESS_KEY_ID }}`
169+
As you can also see in the YAML file, the AWS credentials are accessed using the `${{ secrets.AWS_ACCESS_KEY_ID }}`
167170
syntax.
168-
Make sure to use the name of the Lambda function (as displayed in the AWS console) for the `function_name`
171+
Make sure to use the name of the Lambda function (as displayed in the AWS console) for the `function_name`
169172
property in this configuration file. ("lambda-cd" in this example).
170173

171174
### Procedure: Testing the pipeline

0 commit comments

Comments
 (0)