Skip to content

Commit b80bd1e

Browse files
author
Adetokunbo Ige
committed
chore: update the pulumi stack name
Signed-off-by: Adetokunbo Ige <[email protected]>
1 parent a0caf11 commit b80bd1e

File tree

7 files changed

+54
-18
lines changed

7 files changed

+54
-18
lines changed

.github/workflows/pulumi-deploy.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ on:
1010
jobs:
1111
pulumi-deploy:
1212
runs-on: ubuntu-latest
13-
env:
14-
AWS_REGION: ${{ secrets.AWS_REGION }}
1513

1614
permissions:
1715
id-token: write
@@ -36,16 +34,25 @@ jobs:
3634
run: |
3735
pip install -r requirements.txt
3836
39-
- uses: pulumi/actions@v3
40-
with:
41-
command: preview
42-
stack-name: dev
37+
- name: Configure Pulumi
38+
working-directory: todo-app
39+
run: |
40+
pulumi stack select ExitoLab/todo-app/dev --non-interactive || pulumi stack init ExitoLab/todo-app/dev
4341
env:
4442
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
4543

46-
- uses: pulumi/actions@v3
47-
with:
48-
command: up
49-
stack-name: dev
44+
- name: Pulumi Preview
45+
working-directory: todo-app
46+
run: |
47+
pulumi stack select ExitoLab/todo-app/dev
48+
pulumi preview
49+
env:
50+
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
51+
52+
- name: Pulumi Up
53+
working-directory: todo-app
54+
run: |
55+
pulumi stack select ExitoLab/todo-app/dev
56+
pulumi up --yes
5057
env:
5158
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Building and Deploying a Serverless Todo App on AWS with Docker, Lambda, API Gateway, and GitHub Actions using Pulumi in Python
1+
# Building and Deploying a Serverless Todo App on AWS using Pulumi in Python
22

33
## Overview
44

todo-app/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
*.pyc
22
venv/
3-

todo-app/Pulumi.dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
config:
2-
todo-app:location: eastus
2+
todo-app:docker_image: 289940214902.dkr.ecr.us-east-1.amazonaws.com/todo-app:v1.1

todo-app/Pulumi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ config:
99
pulumi:tags:
1010
value:
1111
pulumi:template: aws-python
12+

todo-app/__main__.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
from pulumi_docker import Image, DockerBuild
44
import pulumi_docker as docker
55

6-
# Step 1: Create an ECR repository
7-
docker_image = "289940214902.dkr.ecr.us-east-1.amazonaws.com/todo-app:v1.1"
6+
from pulumi import Config
7+
8+
# Create a config object to access configuration values
9+
config = pulumi.Config()
10+
11+
docker_image = config.get("docker_image")
812

913
# Create an IAM Role for the Lambda function
1014
lambda_role = aws.iam.Role("lambdaExecutionRole",
@@ -29,6 +33,31 @@
2933
policy_arn="arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
3034
)
3135

36+
# Define a DynamoDB table
37+
dynamodb_table = aws.dynamodb.Table("todo",
38+
hash_key="id", # Partition key
39+
range_key="timestamp", # Optional, sort key
40+
attributes=[
41+
aws.dynamodb.TableAttributeArgs(
42+
name="id",
43+
type="S" # S = String, N = Number, B = Binary
44+
),
45+
aws.dynamodb.TableAttributeArgs(
46+
name="timestamp",
47+
type="N" # Timestamp as a Number
48+
),
49+
],
50+
billing_mode="PROVISIONED", # Billing mode can be "PROVISIONED" or "PAY_PER_REQUEST"
51+
provisioned_throughput=aws.dynamodb.TableProvisionedThroughputArgs(
52+
read_capacity_units=5,
53+
write_capacity_units=5
54+
),
55+
tags={
56+
"Environment": "dev",
57+
"Created_By": "Pulumi",
58+
}
59+
)
60+
3261
# Create a Lambda function using the Docker image
3362
lambda_function = aws.lambda_.Function("my-serverless-function",
3463
name="my-serverless-function",
@@ -65,15 +94,13 @@
6594
type="AWS_PROXY",
6695
uri=lambda_function.invoke_arn) # Ensure lambda_function is defined
6796

68-
6997
lambda_permission = aws.lambda_.Permission("api-gateway-lambda-permission",
7098
action="lambda:InvokeFunction",
7199
function=lambda_function.name,
72100
principal="apigateway.amazonaws.com",
73101
source_arn=pulumi.Output.concat(api.execution_arn, "/*/*")
74102
)
75103

76-
77104
# Deployment of the API, explicitly depends on method and integration to avoid timing issues
78105
deployment = aws.apigateway.Deployment("api-deployment",
79106
rest_api=api.id,

todo-app/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
pulumi>=3.0.0,<4.0.0
22
pulumi-aws>=6.0.2,<7.0.0
33
pulumi_docker==3.4.0
4-
setuptools
4+
setuptools
5+
6+

0 commit comments

Comments
 (0)