Skip to content

Commit 12a7b02

Browse files
authored
Merge pull request #3185 from aws/release-v1.68.0
Release 1.68.0 (to main)
2 parents d100983 + 7222440 commit 12a7b02

37 files changed

+4713
-1232
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: Report a bug concerning the AWS SAM transform
44
title: ''
5-
labels: stage/needs-triage, type/bug
5+
labels: stage/needs-triage
66
assignees: ''
77

88
---

DEVELOPMENT_GUIDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ each version and flip between them (sourcing the activate script). Typically, we
129129
one python version locally and then have our ci (appveyor) run all supported versions.
130130

131131
### Transform tests
132+
133+
Transform tests ensure a SAM template transforms into the expected CloudFormation template.
134+
132135
When adding new transform tests, we have provided a script to help generate the transform test input
133136
and output files in the correct directory given a template.yaml file.
134137
```bash

integration/combination/test_api_settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from parameterized import parameterized
66

77
from integration.config.service_names import REST_API
8-
from integration.helpers.base_test import BaseTest
8+
from integration.helpers.base_test import BaseTest, nonblocking
99
from integration.helpers.resource import current_region_does_not_support
1010

1111

@@ -67,6 +67,7 @@ def test_request_models(self, file_name):
6767
+ " }\n}",
6868
)
6969

70+
@nonblocking
7071
def test_request_parameters_open_api(self):
7172
self.create_and_verify_stack("combination/api_with_request_parameters_openapi")
7273

integration/combination/test_connectors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def tearDown(self):
2626

2727
@parameterized.expand(
2828
[
29+
("combination/connector_appsync_api_to_lambda",),
2930
("combination/connector_appsync_to_lambda",),
3031
("combination/connector_appsync_to_table",),
3132
("combination/connector_function_to_function",),

integration/helpers/base_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
"api_with_custom_domains_regional_ownership_verification",
5555
]
5656

57+
# In general, we should only mark integration tests as @nonblocking if
58+
# 1. The test succeeded every region (this ensures the transformed output makes sense)
59+
# 2. The test resources are defined in a single template without Parameters or other
60+
# CloudFormation macros (this ensures we can represent transform using a transform test)
61+
# 3. An identical transform test exists for the integration test template (this ensures we
62+
# don't break the working template)
63+
nonblocking = pytest.mark.xfail
64+
5765

5866
class BaseTest(TestCase):
5967
@pytest.fixture(autouse=True)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
"LogicalResourceId": "Api",
4+
"ResourceType": "AWS::AppSync::GraphQLApi"
5+
},
6+
{
7+
"LogicalResourceId": "ApiSchema",
8+
"ResourceType": "AWS::AppSync::GraphQLSchema"
9+
},
10+
{
11+
"LogicalResourceId": "NoneDataSource",
12+
"ResourceType": "AWS::AppSync::DataSource"
13+
},
14+
{
15+
"LogicalResourceId": "SayHelloResolver",
16+
"ResourceType": "AWS::AppSync::Resolver"
17+
},
18+
{
19+
"LogicalResourceId": "SayHelloFunc",
20+
"ResourceType": "AWS::AppSync::FunctionConfiguration"
21+
},
22+
{
23+
"LogicalResourceId": "Authorizer",
24+
"ResourceType": "AWS::Lambda::Function"
25+
},
26+
{
27+
"LogicalResourceId": "AuthorizerRole",
28+
"ResourceType": "AWS::IAM::Role"
29+
},
30+
{
31+
"LogicalResourceId": "TriggerFunction",
32+
"ResourceType": "AWS::Lambda::Function"
33+
},
34+
{
35+
"LogicalResourceId": "TriggerFunctionRole",
36+
"ResourceType": "AWS::IAM::Role"
37+
},
38+
{
39+
"LogicalResourceId": "GraphQlApiToLambdaConnectorWriteLambdaPermission",
40+
"ResourceType": "AWS::Lambda::Permission"
41+
}
42+
]
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
Resources:
2+
Api:
3+
Type: AWS::AppSync::GraphQLApi
4+
Properties:
5+
Name: Api
6+
AuthenticationType: AWS_LAMBDA
7+
LambdaAuthorizerConfig:
8+
AuthorizerUri: !GetAtt Authorizer.Arn
9+
10+
ApiSchema:
11+
Type: AWS::AppSync::GraphQLSchema
12+
Properties:
13+
ApiId: !GetAtt Api.ApiId
14+
Definition: |
15+
type Query {
16+
sayHello: String!
17+
}
18+
schema {
19+
query: Query
20+
}
21+
22+
NoneDataSource:
23+
Type: AWS::AppSync::DataSource
24+
Properties:
25+
Type: NONE
26+
ApiId: !GetAtt Api.ApiId
27+
Name: NoneDataSource
28+
29+
SayHelloResolver:
30+
DependsOn: ApiSchema
31+
Type: AWS::AppSync::Resolver
32+
Properties:
33+
ApiId: !GetAtt Api.ApiId
34+
TypeName: Query
35+
FieldName: sayHello
36+
Kind: PIPELINE
37+
PipelineConfig:
38+
Functions:
39+
- !GetAtt SayHelloFunc.FunctionId
40+
Code: |
41+
export function request(ctx) {
42+
return {};
43+
}
44+
45+
export function response(ctx) {
46+
return ctx.prev.result;
47+
}
48+
Runtime:
49+
Name: APPSYNC_JS
50+
RuntimeVersion: 1.0.0
51+
52+
SayHelloFunc:
53+
Type: AWS::AppSync::FunctionConfiguration
54+
Properties:
55+
ApiId: !GetAtt Api.ApiId
56+
Name: SayHelloFunc
57+
DataSourceName: !GetAtt NoneDataSource.Name
58+
Code: |
59+
export function request(ctx) {
60+
return {};
61+
}
62+
63+
export function response(ctx) {
64+
return "Hello World";
65+
}
66+
Runtime:
67+
Name: APPSYNC_JS
68+
RuntimeVersion: 1.0.0
69+
70+
GraphQlApiToLambdaConnector:
71+
Type: AWS::Serverless::Connector
72+
Properties:
73+
Source:
74+
Id: Api
75+
Destination:
76+
Id: Authorizer
77+
Permissions:
78+
- Write
79+
80+
Authorizer:
81+
Type: AWS::Serverless::Function
82+
Properties:
83+
InlineCode: |
84+
exports.handler = async (_) => {
85+
return {
86+
isAuthorized: true,
87+
deniedFields: [],
88+
}
89+
}
90+
PackageType: Zip
91+
Runtime: nodejs14.x
92+
Handler: index.handler
93+
94+
TriggerFunction:
95+
Type: AWS::Serverless::Function
96+
Properties:
97+
Environment:
98+
Variables:
99+
GRAPHQL_URL: !GetAtt Api.GraphQLUrl
100+
Runtime: nodejs14.x
101+
Handler: index.handler
102+
InlineCode: |
103+
const https = require("https");
104+
105+
exports.handler = async (_) => {
106+
const queries = {
107+
sayHello: /* GraphQL */ `
108+
query {
109+
sayHello
110+
}
111+
`,
112+
};
113+
114+
115+
const fetch = async (url, options) =>
116+
new Promise((resolve, reject) => {
117+
const req = https.request(url, options, (res) => {
118+
const body = [];
119+
res.on("data", (chunk) => body.push(chunk));
120+
res.on("end", () => {
121+
const resString = Buffer.concat(body).toString();
122+
resolve(resString);
123+
});
124+
});
125+
126+
req.on("error", (err) => {
127+
reject(err);
128+
});
129+
130+
req.on("timeout", () => {
131+
req.destroy();
132+
reject(new Error("Request time out"));
133+
});
134+
135+
req.write(options.body);
136+
req.end();
137+
});
138+
139+
140+
const makeRequest = async (queryName) => {
141+
const options = {
142+
method: "POST",
143+
headers: {
144+
"Authorization": "n'importe quoi",
145+
},
146+
body: JSON.stringify({ query: queries[queryName] }),
147+
timeout: 10000, // ms
148+
};
149+
150+
const response = await fetch(process.env.GRAPHQL_URL, options);
151+
const body = JSON.parse(response);
152+
const data = body.data?.[queryName];
153+
154+
if (body.errors !== undefined) {
155+
throw JSON.stringify(body.errors);
156+
}
157+
158+
if (data !== "Hello World") {
159+
throw new Error(`${queryName} error: '${data}' must be 'Hello World'`);
160+
}
161+
162+
return body.data;
163+
};
164+
165+
166+
return await makeRequest("sayHello");
167+
};
168+
Metadata:
169+
SamTransformTest: true

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pytest-xdist>=2.5,<4
44
pytest-env>=0.6,<1
55
pytest-rerunfailures>=9.1,<12
66
pyyaml~=6.0
7-
ruff==0.0.261 # loose the requirement once it is more stable
7+
ruff==0.0.263 # loose the requirement once it is more stable
88

99
# Test requirements
1010
pytest>=6.2,<8

ruff.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ select = [
2222
"UP", # pyupgrade
2323
"C4", # flake8-comprehensions
2424
"PTH", # flake8-use-pathlib
25+
"G", # flake8-logging-format
26+
"INP", # flake8-no-pep420
27+
"T20", # flake8-print
2528
]
2629

2730
# Mininal python version we support is 3.7
@@ -33,7 +36,16 @@ keep-runtime-typing = true
3336

3437
[per-file-ignores]
3538
# python scripts in bin/ needs some python path configurations before import
36-
"bin/*.py" = ["E402"] # E402: module-import-not-at-top-of-file
39+
"bin/*.py" = [
40+
# E402: module-import-not-at-top-of-file
41+
"E402",
42+
# S603: `subprocess` call: check for execution of untrusted input
43+
# these are dev tools and do not have risks of malicious inputs.
44+
"S603",
45+
# T201 `print` found
46+
# print() is allowed in bin/ as they are dev tools.
47+
"T201",
48+
]
3749

3850
[pylint]
3951
max-args = 6 # We have many functions reaching 6 args

samtranslator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.67.0"
1+
__version__ = "1.68.0"

0 commit comments

Comments
 (0)