Skip to content

Commit 3bd67bb

Browse files
committed
Added author section
1 parent 66b571a commit 3bd67bb

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

s3-lambda-resizing-python/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Important: this application uses various AWS services and there are costs associ
3030
* Enter a stack name
3131
* Enter the desired AWS Region
3232
* Allow SAM CLI to create IAM roles with the required permissions.
33+
* Enter names for your source and destination S3 buckets. Make sure these are unique as S3 bucket names share a global namespace.
3334
3435
Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in future to use these defaults.
3536
@@ -39,16 +40,16 @@ Important: this application uses various AWS services and there are costs associ
3940
4041
* Use the AWS CLI upload an image to S3
4142
* If the object is a .jpeg or a .png, the code creates a thumbnail and saves it to the target bucket.
42-
* The code assumes that the destination bucket exists and its name is a concatenation of the source bucket name followed by the string -resized
43+
* The code assumes that the destination bucket exists.
4344
4445
==============================================
4546
4647
## Testing
4748
48-
Run the following S3 CLI command to upload an image to the S3 bucket. Note, you must edit the {SourceBucketName} placeholder with the name of the S3 Bucket. This is provided in the stack outputs.
49+
Run the following S3 CLI command to upload an image to the S3 bucket. Note, you must edit the {SourceBucketName} placeholder with the name of the S3 Bucket. This is provided in the stack outputs.
4950
5051
```bash
51-
aws s3 cp './events/white_dog.jpeg' s3://{SourceBucketName}
52+
aws s3 cp './events/white_dog.jpeg' s3://{SourceBucketName}
5253
```
5354

5455
Run the following command to check that a new version of the image has been created in the destination bucket.

s3-lambda-resizing-python/events/event.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"s3SchemaVersion": "1.0",
2121
"configurationId": "828aa6fc-f7b5-4305-8584-487c791949c1",
2222
"bucket": {
23-
"name": "s3sourcebuckett",
23+
"name": "<your-bucket-name-here",
2424
"ownerIdentity": {
2525
"principalId": "A3I5XTEXAMAI3E"
2626
},
2727
"arn": "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df"
2828
},
2929
"object": {
30-
"key": "white_dog.jpeg",
30+
"key": "<your-source-object-key-here>",
3131
"size": 1305107,
3232
"eTag": "b21b84d653bb07b05b1e6b33684dc11b",
3333
"sequencer": "0C0F6F405D6ED209E1"

s3-lambda-resizing-python/example-pattern.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,13 @@
4141
"text": [
4242
"Delete the application: <code>sam delete</code>."
4343
]
44+
},
45+
"authors": [
46+
{
47+
"name": "Seshu Brahma",
48+
"image": "https://i.postimg.cc/ZR0MyrTN/seshub-photo.jpg",
49+
"bio": "SDE II, Lambda, AWS",
50+
"linkedin": "seshu-brahma"
4451
}
52+
]
4553
}

s3-lambda-resizing-python/src/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def lambda_handler(event, context):
2020
upload_path = '/tmp/resized-{}'.format(tmpkey)
2121
s3_client.download_file(bucket, key, download_path)
2222
resize_image(download_path, upload_path)
23-
s3_client.upload_file(upload_path, os.getenv('DestinationBucketName'), 'resized-{}'.format(key))
23+
s3_client.upload_file(upload_path, os.getenv('DESTINATION_BUCKETNAME'), 'resized-{}'.format(key))

s3-lambda-resizing-python/template.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ Description: Image resizing service (tag:s3-lambda-resizing-python)
55
Parameters:
66
SourceBucketName:
77
Type: String
8+
# Pass your bucket name dynamically or change it here
9+
Default: my-source-bucket-name
810
DestinationBucketName:
911
Type: String
12+
# Pass your bucket name dynamically or change it here
13+
Default: my-destination-bucket-name
1014

1115
Resources:
1216
## S3 bucket
@@ -27,7 +31,6 @@ Resources:
2731
Handler: app.lambda_handler
2832
Runtime: python3.12
2933
MemorySize: 2048
30-
Timeout: 60
3134
Layers:
3235
- !Sub 'arn:aws:lambda:${AWS::Region}:175033217214:layer:graphicsmagick:2'
3336
Policies:
@@ -58,4 +61,4 @@ Outputs:
5861
Description: S3 destination Bucket for object storage
5962
FunctionArn:
6063
Value: !Ref ResizerFunction
61-
Description: ResizerFunction function Arn
64+
Description: ResizerFunction function Arn

0 commit comments

Comments
 (0)