Skip to content

Commit

Permalink
Merge pull request #2426 from vamsipulikonda/vamsipulikonda-updated-a…
Browse files Browse the repository at this point in the history
…pigw-s3-proxy

Updating Existing Pattern - apigw-s3-proxy
  • Loading branch information
julianwood authored Sep 3, 2024
2 parents f018500 + 39bad1a commit fe170d6
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apigw-s3-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The API exposes 3 GET methods:

* Root GET method: it provides a list of the S3 buckets of the account where the stack is deployed.
* {folder} GET method: it provides a list of the objects contained in the bucket {folder}
* {item} GET method: it returns the contents of the object {item}.
* {item+} GET method: it returns the contents of the object in Folders and Sub-folders of S3 Bucket {item+}

The template also deploys an IAM role with S3 read-only capabilities that is used by API Gateway to integrate with S3.

Expand Down Expand Up @@ -53,7 +53,7 @@ Important: this application uses various AWS services and there are costs associ
The stack will output the **api endpoint**. Since all the methods are protected with IAM authentication, you can use *Postman* to send a SigV4-signed HTTP request to the API Gateway endpoint.

```
https://12345abcde.execute-api.{region}.amazonaws.com/Prod/mybucket/myobject.txt
https://12345abcde.execute-api.{region}.amazonaws.com/Prod/mybucket/folder1/folder2/index.html
```

## Cleanup
Expand Down
79 changes: 79 additions & 0 deletions apigw-s3-proxy/apigw-s3-proxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"title": "Amazon API Gateway with a Amazon S3 integration",
"description": "Create a REST API Gateway with a S3 read-only integration",
"language": "",
"level": "200",
"framework": "SAM",
"introBox": {
"headline": "How it works",
"text": [
"This pattern deploys an Amazon API Gateway REST API endpoint with a S3 read-only integration",
"The API exposes 3 GET methods:",
"Root GET method: it provides a list of the S3 buckets of the account where the stack is deployed.",
"{folder} GET method: it provides a list of the objects contained in the bucket {folder}",
"{item} GET method: it returns the contents of the object in Folders and Sub-folders {item+}",
"The template also deploys an IAM role with S3 read-only capabilities that is used by API Gateway to integrate with S3.",
"Since this is API Gateway effectively acts as a proxy S3, every GET method is protected by IAM authentication to prevent public access."
]
},
"gitHub": {
"template": {
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-s3-proxy",
"templateURL": "serverless-patterns/apigw-s3-proxy",
"projectFolder": "apigw-s3-proxy",
"templateFile": "template.yaml"
}
},
"resources": {
"bullets": [
{
"text": "REST API with S3 integration",
"link": "https://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html"
}
]
},
"deploy": {
"text": [
"Deploy the stack: <code>sam deploy</code>."
]
},
"testing": {
"text": [
"Once the application is deployed, retrieve the API URL provided as output and open it in a browser page.",
"Replace the folder and item place holder with S3 bucket name and path to your file",
"Example: https://12345abcde.execute-api.{region}.amazonaws.com/Prod/mybucket/folder1/folder2/index.html"
]
},
"cleanup": {
"text": [
"Delete the stack: <code>sam delete</code>."
]
},
"authors": [
{
"name": "Vamsi Pulikonda",
"image": "https://raw.githubusercontent.com/vamsipulikonda/my-photo/main/vamsi-photo.jpg",
"bio": "I am a cloud computing enthusiast working as a Cloud Engineer at Amazon Web Services.",
"linkedin": "vamsipulikonda"
}
],
"patternArch": {
"icon1": {
"x": 20,
"y": 50,
"service": "apigw",
"label": "API Gateway REST API"
},
"icon2": {
"x": 80,
"y": 50,
"service": "s3",
"label": "Amazon S3"
},
"line1": {
"from": "icon1",
"to": "icon2",
"label": ""
}
}
}
61 changes: 61 additions & 0 deletions apigw-s3-proxy/example-pattern.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"title": "Amazon API Gateway with a S3 integration",
"description": "Create a REST API Gateway with a S3 read-only integration",
"language": "",
"level": "200",
"framework": "SAM",
"introBox": {
"headline": "How it works",
"text": [
"This pattern deploys an Amazon API Gateway REST API endpoint with a S3 read-only integration",
"The API exposes 3 GET methods:",
"Root GET method: it provides a list of the S3 buckets of the account where the stack is deployed.",
"{folder} GET method: it provides a list of the objects contained in the bucket {folder}",
"{item} GET method: it returns the contents of the object in Folders and Sub-folders {item+}",
"The template also deploys an IAM role with S3 read-only capabilities that is used by API Gateway to integrate with S3.",
"Since this is API Gateway effectively acts as a proxy S3, every GET method is protected by IAM authentication to prevent public access."
]
},
"gitHub": {
"template": {
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-s3-proxy",
"templateURL": "serverless-patterns/apigw-s3-proxy",
"projectFolder": "apigw-s3-proxy",
"templateFile": "template.yaml"
}
},
"resources": {
"bullets": [
{
"text": "REST API with S3 integration",
"link": "https://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html"
}
]
},
"deploy": {
"text": [
"Deploy the stack: <code>sam deploy</code>."
]
},
"testing": {
"text": [
"Once the application is deployed, retrieve the API URL provided as output and open it in a browser page.",
"Replace the folder and item place holder with S3 bucket name and path to your file",
"Example: https://12345abcde.execute-api.{region}.amazonaws.com/Prod/mybucket/folder1/folder2/index.html"
]
},
"cleanup": {
"text": [
"Delete the stack: <code>sam delete</code>."
]
},
"authors": [
{
"name": "Vamsi Pulikonda",
"image": "https://raw.githubusercontent.com/vamsipulikonda/my-photo/main/vamsi-photo.jpg",
"bio": "I am a cloud computing enthusiast working as a Cloud Engineer at Amazon Web Services.",
"linkedin": "vamsipulikonda"
}
]
}

4 changes: 2 additions & 2 deletions apigw-s3-proxy/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Resources:
Properties:
RestApiId: !Ref AppApi
ParentId: !Ref ResourceFolder
PathPart: '{item}'
PathPart: '{item+}'

RootMethodGet:
Type: AWS::ApiGateway::Method
Expand Down Expand Up @@ -146,4 +146,4 @@ Outputs:
# API Gateway endpoint to be used during tests
AppApiEndpoint:
Description: API Endpoint
Value: !Sub "https://${AppApi}.execute-api.${AWS::Region}.amazonaws.com/Prod"
Value: !Sub "https://${AppApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/{folder}/{item+}"

0 comments on commit fe170d6

Please sign in to comment.