Skip to content

Commit 9977dd5

Browse files
committed
pinpoint sms apigw updated files and _pattern-model folder
1 parent 84d6c8b commit 9977dd5

8 files changed

Lines changed: 226 additions & 135 deletions

File tree

_pattern-model/README.md

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
# Pinpoint SMS using API Gateway and Lambda
1+
# AWS Service 1 to AWS Service 2
22

3-
This pattern shows an example how a phone number can be validated and how a SMS message can be send using Pinpoint APIs which via API Gateway and Lambda deployed using SAM.
4-
5-
As a pre-requisite, a Pinpoint Application has to be created and its SMS channel should be enabled. Subsequently, this stack can be deployed with pinpoint application id, destination phone number, message that has to be sent, origination number and message type. Please read more about the Pinpoint API calls utilised here:
6-
https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messagespost
7-
8-
https://docs.aws.amazon.com/pinpoint/latest/apireference/phone-number-validate.html
3+
This pattern << explain usage >>
94

105
Learn more about this pattern at Serverless Land Patterns: << Add the live URL here >>
116

@@ -26,7 +21,7 @@ Important: this application uses various AWS services and there are costs associ
2621
```
2722
1. Change directory to the pattern directory:
2823
```
29-
cd serverless-patterns/apigw-lambda-pinpoint
24+
cd _patterns-model
3025
```
3126
1. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
3227
```
@@ -43,30 +38,11 @@ Important: this application uses various AWS services and there are costs associ
4338
4439
## How it works
4540
46-
1. Depending on the country to which SMS messages has to be sent, an [origination number](https://docs.aws.amazon.com/pinpoint/latest/userguide/settings-sms-request-number.html) can be requested accordingly.
47-
48-
2. Next, the SMS message can be sent using the API Gateway deployed via stack.
49-
50-
3. The lambda function's code firstly verify the phone number by using the [phone number validate](https://docs.aws.amazon.com/pinpoint/latest/apireference/phone-number-validate.html) API call.
41+
Explain how the service interaction works.
5142
5243
## Testing
5344
54-
1. You can make a request to API Gateway with the following payload:
55-
56-
```
57-
{
58-
"destination_number": "",
59-
"message": "",
60-
"pinpoint_app_id": "",
61-
"origination_number": "",
62-
"message_type": ""
63-
}
64-
```
65-
2. If the message is sent successfully, then you will receive the following response:
66-
67-
```
68-
Message sent! Message ID: <random message id>
69-
```
45+
Provide steps to trigger the integration and show what should be observed if successful.
7046
7147
## Cleanup
7248

_pattern-model/example-pattern.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
{
2-
"title": "Pinpoint SMS via API Gateway and Lambda",
3-
"description": "Validate phone number and send SMS from Pinpoint via API Gateway and Lambda",
2+
"title": "Step Functions to Athena",
3+
"description": "Create a Step Functions workflow to query Amazon Athena.",
44
"language": "Python",
55
"level": "200",
6-
"framework": "SAM",
6+
"framework": "CDK",
77
"introBox": {
88
"headline": "How it works",
99
"text": [
10-
"This pattern shows an example how a phone number can be validated and how a SMS message can be send using Pinpoint APIs which via API Gateway and Lambda deployed using SAM."
10+
"This sample project demonstrates how to use an AWS Step Functions state machine to query Athena and get the results. This pattern is leveraging the native integration between these 2 services which means only JSON-based, structured language is used to define the implementation.",
11+
"With Amazon Athena you can get up to 1000 results per invocation of the GetQueryResults method and this is the reason why the Step Function has a loop to get more results. The results are sent to a Map which can be configured to handle (the DoSomething state) the items in parallel or one by one by modifying the max_concurrency parameter.",
12+
"This pattern deploys one Step Functions, two S3 Buckets, one Glue table and one Glue database."
1113
]
1214
},
1315
"gitHub": {
1416
"template": {
15-
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-lambda-pinpoint",
16-
"templateURL": "serverless-patterns/apigw-lambda-pinpoint",
17-
"projectFolder": "apigw-lambda-pinpoint",
18-
"templateFile": "template.py"
17+
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/sfn-athena-cdk-python",
18+
"templateURL": "serverless-patterns/sfn-athena-cdk-python",
19+
"projectFolder": "sfn-athena-cdk-python",
20+
"templateFile": "sfn_athena_cdk_python/sfn_athena_cdk_python_stack.py"
1921
}
2022
},
2123
"resources": {
2224
"bullets": [
2325
{
24-
"text": "Send Messages Pinpoint",
25-
"link": "https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messagespost"
26+
"text": "Call Athena with Step Functions",
27+
"link": "https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.html"
2628
},
2729
{
28-
"text": "Phone number validate",
29-
"link": "https://docs.aws.amazon.com/pinpoint/latest/apireference/phone-number-validate.html"
30+
"text": "Amazon Athena - Serverless Interactive Query Service",
31+
"link": "https://aws.amazon.com/athena/"
3032
}
3133
]
3234
},
@@ -42,15 +44,15 @@
4244
},
4345
"cleanup": {
4446
"text": [
45-
"Delete the stack: <code>sam delete --stack-name STACK_NAME</code>."
47+
"Delete the stack: <code>cdk delete</code>."
4648
]
4749
},
4850
"authors": [
4951
{
50-
"name": "Sahil Malhotra",
52+
"name": "Your name",
5153
"image": "link-to-your-photo.jpg",
52-
"bio": "Serverless enthusiast",
53-
"linkedin": "https://www.linkedin.com/in/smalhotraa/",
54+
"bio": "Your bio.",
55+
"linkedin": "linked-in-ID",
5456
"twitter": "twitter-handle"
5557
}
5658
]

_pattern-model/template.yaml

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,16 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
3+
Description: Serverless patterns - Service to Service description
4+
5+
# Comment on each global
6+
Globals:
7+
8+
9+
# Comment each resource section to explain usage
310
Resources:
4-
Api:
5-
Type: AWS::Serverless::Api
6-
Properties:
7-
Name: !Sub
8-
- ${ResourceName} From Stack ${AWS::StackName}
9-
- ResourceName: PinpointSMSApigw
10-
StageName: Prod
11-
DefinitionBody:
12-
openapi: '3.0'
13-
info: {}
14-
paths:
15-
/send_message:
16-
post:
17-
x-amazon-apigateway-integration:
18-
httpMethod: POST
19-
type: aws_proxy
20-
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PinpointFunction.Arn}/invocations
21-
responses: {}
22-
EndpointConfiguration: REGIONAL
23-
TracingEnabled: true
24-
PinpointFunction:
25-
Type: AWS::Serverless::Function
26-
Properties:
27-
Description: !Sub
28-
- Stack ${AWS::StackName} Function ${ResourceName}
29-
- ResourceName: PinpointFunction
30-
CodeUri: code/
31-
Handler: lambda_function.lambda_handler
32-
Runtime: python3.9
33-
MemorySize: 3008
34-
Timeout: 30
35-
Tracing: Active
36-
Events:
37-
ApiPOSTsendmessage:
38-
Type: Api
39-
Properties:
40-
Path: /send_message
41-
Method: POST
42-
RestApiId: !Ref Api
43-
Policies:
44-
- Statement:
45-
- Effect: Allow
46-
Action:
47-
- "mobiletargeting:PhoneNumberValidate"
48-
Resource: !Join
49-
- ""
50-
- - "arn:aws:mobiletargeting:*:"
51-
- !Ref AWS::AccountId
52-
- ":phone/number/validate"
53-
- Effect: Allow
54-
Action:
55-
- "mobiletargeting:SendMessages"
56-
Resource: !Join
57-
- ""
58-
- - "arn:aws:mobiletargeting:*:"
59-
- !Ref AWS::AccountId
60-
- ":apps/*/messages"
11+
12+
13+
# List all common outputs for usage
14+
Outputs:
15+
6116

apigw-lambda-pinpoint/README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# AWS Service 1 to AWS Service 2
1+
# Pinpoint SMS using API Gateway and Lambda
22

3-
This pattern << explain usage >>
3+
This pattern shows an example how a phone number can be validated and how a SMS message can be send using Pinpoint APIs which via API Gateway and Lambda deployed using SAM.
4+
5+
As a pre-requisite, a Pinpoint Application has to be created and its SMS channel should be enabled. Subsequently, this stack can be deployed with pinpoint application id, destination phone number, message that has to be sent, origination number and message type. Please read more about the Pinpoint API calls utilised here:
6+
https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messagespost
7+
8+
https://docs.aws.amazon.com/pinpoint/latest/apireference/phone-number-validate.html
49

510
Learn more about this pattern at Serverless Land Patterns: << Add the live URL here >>
611

@@ -21,7 +26,7 @@ Important: this application uses various AWS services and there are costs associ
2126
```
2227
1. Change directory to the pattern directory:
2328
```
24-
cd _patterns-model
29+
cd serverless-patterns/apigw-lambda-pinpoint
2530
```
2631
1. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
2732
```
@@ -38,11 +43,30 @@ Important: this application uses various AWS services and there are costs associ
3843
3944
## How it works
4045
41-
Explain how the service interaction works.
46+
1. Depending on the country to which SMS messages has to be sent, an [origination number](https://docs.aws.amazon.com/pinpoint/latest/userguide/settings-sms-request-number.html) can be requested accordingly.
47+
48+
2. Next, the SMS message can be sent using the API Gateway deployed via stack.
49+
50+
3. The lambda function's code firstly verify the phone number by using the [phone number validate](https://docs.aws.amazon.com/pinpoint/latest/apireference/phone-number-validate.html) API call.
4251
4352
## Testing
4453
45-
Provide steps to trigger the integration and show what should be observed if successful.
54+
1. You can make a request to API Gateway with the following payload:
55+
56+
```
57+
{
58+
"destination_number": "",
59+
"message": "",
60+
"pinpoint_app_id": "",
61+
"origination_number": "",
62+
"message_type": ""
63+
}
64+
```
65+
2. If the message is sent successfully, then you will receive the following response:
66+
67+
```
68+
Message sent! Message ID: <random message id>
69+
```
4670
4771
## Cleanup
4872

apigw-lambda-pinpoint/example-pattern.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
{
2-
"title": "Step Functions to Athena",
3-
"description": "Create a Step Functions workflow to query Amazon Athena.",
2+
"title": "Pinpoint SMS via API Gateway and Lambda",
3+
"description": "Validate phone number and send SMS from Pinpoint via API Gateway and Lambda",
44
"language": "Python",
55
"level": "200",
6-
"framework": "CDK",
6+
"framework": "SAM",
77
"introBox": {
88
"headline": "How it works",
99
"text": [
10-
"This sample project demonstrates how to use an AWS Step Functions state machine to query Athena and get the results. This pattern is leveraging the native integration between these 2 services which means only JSON-based, structured language is used to define the implementation.",
11-
"With Amazon Athena you can get up to 1000 results per invocation of the GetQueryResults method and this is the reason why the Step Function has a loop to get more results. The results are sent to a Map which can be configured to handle (the DoSomething state) the items in parallel or one by one by modifying the max_concurrency parameter.",
12-
"This pattern deploys one Step Functions, two S3 Buckets, one Glue table and one Glue database."
10+
"This pattern shows an example how a phone number can be validated and how a SMS message can be send using Pinpoint APIs which via API Gateway and Lambda deployed using SAM."
1311
]
1412
},
1513
"gitHub": {
1614
"template": {
17-
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/sfn-athena-cdk-python",
18-
"templateURL": "serverless-patterns/sfn-athena-cdk-python",
19-
"projectFolder": "sfn-athena-cdk-python",
20-
"templateFile": "sfn_athena_cdk_python/sfn_athena_cdk_python_stack.py"
15+
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-lambda-pinpoint",
16+
"templateURL": "serverless-patterns/apigw-lambda-pinpoint",
17+
"projectFolder": "apigw-lambda-pinpoint",
18+
"templateFile": "template.py"
2119
}
2220
},
2321
"resources": {
2422
"bullets": [
2523
{
26-
"text": "Call Athena with Step Functions",
27-
"link": "https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.html"
24+
"text": "Send Messages Pinpoint",
25+
"link": "https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messagespost"
2826
},
2927
{
30-
"text": "Amazon Athena - Serverless Interactive Query Service",
31-
"link": "https://aws.amazon.com/athena/"
28+
"text": "Phone number validate",
29+
"link": "https://docs.aws.amazon.com/pinpoint/latest/apireference/phone-number-validate.html"
3230
}
3331
]
3432
},
@@ -44,15 +42,15 @@
4442
},
4543
"cleanup": {
4644
"text": [
47-
"Delete the stack: <code>cdk delete</code>."
45+
"Delete the stack: <code>sam delete --stack-name STACK_NAME</code>."
4846
]
4947
},
5048
"authors": [
5149
{
52-
"name": "Your name",
50+
"name": "Sahil Malhotra",
5351
"image": "link-to-your-photo.jpg",
54-
"bio": "Your bio.",
55-
"linkedin": "linked-in-ID",
52+
"bio": "Serverless enthusiast",
53+
"linkedin": "https://www.linkedin.com/in/smalhotraa/",
5654
"twitter": "twitter-handle"
5755
}
5856
]

apigw-lambda-pinpoint/src/app.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)