Skip to content

Commit 81581dc

Browse files
authored
fix: gen 1 update python to 3.12 for searchable lambda (#3373)
<!-- Please make sure to read the Pull Request Guidelines: https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#pull-requests --> #### Description of changes <!-- Thank you for your Pull Request! Please provide a description above and review the requirements below. --> ##### CDK / CloudFormation Parameters Changed <!-- Please list any changes to the CDK/CFN params, with a link to references https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html e.g. * Conditionally added support for `Code` based AppSync Functions: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-code * Conditionally added support for `Code` based AppSync Resolvers: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-code --> #### Issue #, if available aws-amplify/amplify-cli#14249 #### Description of how you validated changes #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] PR description included - [ ] `yarn test` passes - [ ] E2E test run linked - [ ] Tests are [changed or added](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#tests) - [ ] Relevant documentation is changed or added (and PR referenced) - [ ] New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies - [ ] Any CDK or CloudFormation parameter changes are called out explicitly By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 966e2fb commit 81581dc

File tree

8 files changed

+18
-8
lines changed

8 files changed

+18
-8
lines changed

packages/amplify-graphql-searchable-transformer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"access": "public"
2222
},
2323
"scripts": {
24-
"build": "tsc && cd streaming-lambda && bestzip --force node ../lib/streaming-lambda.zip python_streaming_function.py",
24+
"build": "tsc && cd streaming-lambda && rm -rf dist && mkdir -p dist && cp python_streaming_function.py dist/ && pip3 install -r requirements.txt -t dist/ --upgrade && cd dist && bestzip --force node ../../lib/streaming-lambda.zip . && cd .. && rm -rf dist",
2525
"watch": "tsc -w",
26-
"clean": "rimraf ./lib",
26+
"clean": "rimraf ./lib ./streaming-lambda/dist",
2727
"test": "jest",
2828
"extract-api": "ts-node ../../scripts/extract-api.ts"
2929
},
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Build output
2+
dist/
3+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
boto3>=1.28.0
2+
botocore>=1.31.0

packages/graphql-elasticsearch-transformer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"aws"
1818
],
1919
"scripts": {
20-
"build": "tsc && cd streaming-lambda && bestzip --force node ../lib/streaming-lambda.zip python_streaming_function.py",
20+
"build": "tsc && cd streaming-lambda && rm -rf dist && mkdir -p dist && cp python_streaming_function.py dist/ && pip3 install -r requirements.txt -t dist/ --upgrade && cd dist && bestzip --force node ../../lib/streaming-lambda.zip . && cd .. && rm -rf dist",
2121
"watch": "tsc -w",
22-
"clean": "rimraf ./lib",
22+
"clean": "rimraf ./lib ./streaming-lambda/dist",
2323
"test": "jest",
2424
"extract-api": "ts-node ../../scripts/extract-api.ts"
2525
},

packages/graphql-elasticsearch-transformer/src/resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class ResourceFactory {
4747
Description:
4848
'The lambda runtime \
4949
(https://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html#SSS-CreateFunction-request-Runtime)',
50-
Default: 'python3.9',
50+
Default: 'python3.12',
5151
}),
5252
[ResourceConstants.PARAMETERS.ElasticsearchStreamingFunctionName]: new StringParameter({
5353
Description: 'The name of the streaming lambda function.',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Build output
2+
dist/

packages/graphql-elasticsearch-transformer/streaming-lambda/python_streaming_function.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from botocore.auth import SigV4Auth
1111
from botocore.awsrequest import AWSRequest
1212
from botocore.credentials import get_credentials
13-
from botocore.endpoint import BotocoreHTTPSession
13+
from botocore.httpsession import URLLib3Session
1414
from botocore.session import Session
1515
from boto3.dynamodb.types import TypeDeserializer
1616

@@ -68,7 +68,7 @@ def post_data_to_es(payload, region, creds, host, path, method='POST', proto='ht
6868
req = AWSRequest(method=method, url=proto + host +
6969
quote(path), data=payload, headers={'Host': host, 'Content-Type': 'application/json'})
7070
SigV4Auth(creds, 'es', region).add_auth(req)
71-
http_session = BotocoreHTTPSession()
71+
http_session = URLLib3Session()
7272
res = http_session.send(req.prepare())
7373
if res.status_code >= 200 and res.status_code <= 299:
7474
return res._content
@@ -83,7 +83,8 @@ def post_to_es(payload):
8383

8484
# Get aws_region and credentials to post signed URL to ES
8585
es_region = ES_REGION or os.environ['AWS_REGION']
86-
session = Session({'region': es_region})
86+
session = Session()
87+
session.set_config_variable('region', es_region)
8788
creds = get_credentials(session)
8889
es_url = urlparse(ES_ENDPOINT)
8990
# Extract the domain name in ES_ENDPOINT
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
boto3>=1.28.0
2+
botocore>=1.31.0

0 commit comments

Comments
 (0)