Skip to content

Commit bedb81b

Browse files
author
Connor Robertson
authored
Merge pull request #3431 from aws/release-v1.81.0
Release 1.81.0 (to main)
2 parents cb11c8e + 47361e1 commit bedb81b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6604
-176
lines changed

integration/combination/test_connectors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def tearDown(self):
6262
("combination/connector_appsync_api_to_lambda",),
6363
("combination/connector_appsync_to_lambda",),
6464
("combination/connector_appsync_to_table",),
65+
("combination/connector_appsync_to_eventbus",),
6566
("combination/connector_function_to_function",),
6667
("combination/connector_restapi_to_function",),
6768
("combination/connector_httpapi_to_function",),
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"LogicalResourceId": "ApiKey",
4+
"ResourceType": "AWS::AppSync::ApiKey"
5+
},
6+
{
7+
"LogicalResourceId": "ApiSchema",
8+
"ResourceType": "AWS::AppSync::GraphQLSchema"
9+
},
10+
{
11+
"LogicalResourceId": "AppSyncApi",
12+
"ResourceType": "AWS::AppSync::GraphQLApi"
13+
},
14+
{
15+
"LogicalResourceId": "AppSyncEventBusDataSource",
16+
"ResourceType": "AWS::AppSync::DataSource"
17+
},
18+
{
19+
"LogicalResourceId": "AppSyncSayHelloResolver",
20+
"ResourceType": "AWS::AppSync::Resolver"
21+
},
22+
{
23+
"LogicalResourceId": "ConnectorPolicy",
24+
"ResourceType": "AWS::IAM::ManagedPolicy"
25+
},
26+
{
27+
"LogicalResourceId": "EventBridgeRole",
28+
"ResourceType": "AWS::IAM::Role"
29+
},
30+
{
31+
"LogicalResourceId": "EventBus",
32+
"ResourceType": "AWS::Events::EventBus"
33+
},
34+
{
35+
"LogicalResourceId": "TriggerFunction",
36+
"ResourceType": "AWS::Lambda::Function"
37+
}
38+
]
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
Resources:
2+
EventBus:
3+
Type: AWS::Events::EventBus
4+
Properties:
5+
Name: !Sub "${AWS::StackName}-EventBus"
6+
7+
EventBridgeRole:
8+
Type: AWS::IAM::Role
9+
Properties:
10+
AssumeRolePolicyDocument:
11+
Version: '2012-10-17'
12+
Statement:
13+
- Effect: Allow
14+
Action:
15+
- sts:AssumeRole
16+
Principal:
17+
Service:
18+
- appsync.amazonaws.com
19+
- lambda.amazonaws.com
20+
21+
AppSyncApi:
22+
Type: AWS::AppSync::GraphQLApi
23+
Properties:
24+
Name: AppSyncApi
25+
AuthenticationType: API_KEY
26+
27+
ApiSchema:
28+
Type: AWS::AppSync::GraphQLSchema
29+
Properties:
30+
ApiId: !GetAtt AppSyncApi.ApiId
31+
Definition: |
32+
type EntryDetails {
33+
ErrorCode: String
34+
ErrorMessage: String
35+
EventId: String!
36+
}
37+
38+
type PutEventsResult {
39+
Entries: [EntryDetails!]!
40+
FailedEntry: Int
41+
}
42+
43+
type Query {
44+
sayHello: PutEventsResult!
45+
}
46+
47+
schema {
48+
query: Query
49+
}
50+
51+
AppSyncEventBusDataSource:
52+
Type: AWS::AppSync::DataSource
53+
Properties:
54+
ApiId: !GetAtt AppSyncApi.ApiId
55+
Name: AppSyncEventBusDataSource
56+
Type: AMAZON_EVENTBRIDGE
57+
ServiceRoleArn: !GetAtt EventBridgeRole.Arn
58+
EventBridgeConfig:
59+
EventBusArn: !GetAtt 'EventBus.Arn'
60+
61+
AppSyncSayHelloResolver:
62+
DependsOn: ApiSchema
63+
Type: AWS::AppSync::Resolver
64+
Properties:
65+
ApiId: !GetAtt AppSyncApi.ApiId
66+
TypeName: Query
67+
FieldName: sayHello
68+
DataSourceName: !GetAtt AppSyncEventBusDataSource.Name
69+
Runtime:
70+
Name: APPSYNC_JS
71+
RuntimeVersion: 1.0.0
72+
Code: |
73+
import { util } from '@aws-appsync/utils';
74+
export function request(ctx) {
75+
return {
76+
"operation" : "PutEvents",
77+
"events" : [{
78+
"source": "com.mycompany.myapp",
79+
"detail": {
80+
"key1" : "value1",
81+
"key2" : "value2"
82+
},
83+
"resources": ["Resource1", "Resource2"],
84+
"detailType": "myDetailType"
85+
}]
86+
}
87+
}
88+
89+
export function response(ctx) {
90+
if(ctx.error)
91+
util.error(ctx.error.message, ctx.error.type, ctx.result)
92+
else
93+
return ctx.result
94+
}
95+
96+
Connector:
97+
Type: AWS::Serverless::Connector
98+
Properties:
99+
Source:
100+
Id: AppSyncEventBusDataSource
101+
Destination:
102+
Id: EventBus
103+
Permissions:
104+
- Write
105+
106+
ApiKey:
107+
Type: AWS::AppSync::ApiKey
108+
Properties:
109+
ApiId: !GetAtt AppSyncApi.ApiId
110+
111+
TriggerFunction:
112+
Type: AWS::Serverless::Function
113+
Properties:
114+
Role: !GetAtt EventBridgeRole.Arn
115+
Environment:
116+
Variables:
117+
API_KEY: !GetAtt ApiKey.ApiKey
118+
GRAPHQL_URL: !GetAtt AppSyncApi.GraphQLUrl
119+
EventBusName: !Ref EventBus
120+
Runtime: nodejs16.x
121+
Handler: index.handler
122+
InlineCode: |
123+
const https = require("https");
124+
125+
exports.handler = async () => {
126+
const queries = {
127+
sayHello: /* GraphQL */ `
128+
query {
129+
sayHello {
130+
Entries {
131+
ErrorCode
132+
EventId
133+
ErrorMessage
134+
}
135+
FailedEntry
136+
}
137+
}
138+
`,
139+
};
140+
141+
const fetch = async (url, options) =>
142+
new Promise((resolve, reject) => {
143+
const req = https.request(url, options, (res) => {
144+
const body = [];
145+
res.on("data", (chunk) => body.push(chunk));
146+
res.on("end", () => {
147+
const resString = Buffer.concat(body).toString();
148+
resolve(resString);
149+
});
150+
});
151+
req.on("error", (err) => {
152+
reject(err);
153+
});
154+
req.on("timeout", () => {
155+
req.destroy();
156+
reject(new Error("Request time out"));
157+
});
158+
req.write(options.body);
159+
req.end();
160+
});
161+
162+
const makeRequest = async (queryName) => {
163+
const options = {
164+
method: "POST",
165+
headers: {
166+
"x-api-key": process.env.API_KEY,
167+
},
168+
body: JSON.stringify({ query: queries[queryName] }),
169+
timeout: 600000, // ms
170+
};
171+
172+
const response = await fetch(process.env.GRAPHQL_URL, options);
173+
let body = JSON.parse(response);
174+
const data = body.data?.[queryName];
175+
176+
if (body.errors !== undefined) {
177+
throw JSON.stringify(body.errors);
178+
}
179+
180+
if (data.FailedEntry != null || data.ErrorCode != null ) {
181+
throw new Error(
182+
`${queryName} error: failed to send event to eventbus ${process.env.EventBusName}`);
183+
}
184+
185+
return body.data;
186+
};
187+
188+
await makeRequest("sayHello");
189+
};
190+
191+
Metadata:
192+
SamTransformTest: true

integration/single/test_basic_state_machine.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def test_basic_state_machine_with_tags(self):
3434
self._verify_tag_presence(tags, "TagOne", "ValueOne")
3535
self._verify_tag_presence(tags, "TagTwo", "ValueTwo")
3636

37+
@skipIf(
38+
current_region_does_not_support([STATE_MACHINE_INLINE_DEFINITION]),
39+
"StateMachine with inline definition is not supported in this testing region",
40+
)
3741
def test_state_machine_with_role_path(self):
3842
"""
3943
Creates a State machine with a Role Path

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ filterwarnings =
2020
ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning
2121
# Pytest warnings
2222
ignore::pytest.PytestUnraisableExceptionWarning
23+
# https://github.com/urllib3/urllib3/blob/main/src/urllib3/poolmanager.py#L313
24+
ignore::DeprecationWarning:urllib3.*:

samtranslator/__init__.py

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

samtranslator/internal/schema_source/aws_serverless_function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ class Properties(BaseModel):
628628
SnapStart: Optional[SnapStart] = prop("SnapStart")
629629
RuntimeManagementConfig: Optional[RuntimeManagementConfig] = prop("RuntimeManagementConfig")
630630
Tags: Optional[Tags] = prop("Tags")
631-
PropagateTags: Optional[bool] # TODO: add docs
631+
PropagateTags: Optional[bool] = prop("PropagateTags")
632632
Timeout: Optional[Timeout] = prop("Timeout")
633633
Tracing: Optional[Tracing] = prop("Tracing")
634634
VersionDescription: Optional[PassThroughProp] = prop("VersionDescription")
@@ -659,7 +659,7 @@ class Globals(BaseModel):
659659
["AWS::Lambda::Function", "Properties", "Environment"],
660660
)
661661
Tags: Optional[Tags] = prop("Tags")
662-
PropagateTags: Optional[bool] # TODO: add docs
662+
PropagateTags: Optional[bool] = prop("PropagateTags")
663663
Tracing: Optional[Tracing] = prop("Tracing")
664664
KmsKeyArn: Optional[KmsKeyArn] = prop("KmsKeyArn")
665665
Layers: Optional[Layers] = prop("Layers")

samtranslator/internal/schema_source/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ class ResourceAttributes(BaseModel):
9999
Metadata: Optional[PassThroughProp]
100100
UpdateReplacePolicy: Optional[PassThroughProp]
101101
Condition: Optional[PassThroughProp]
102+
IgnoreGlobals: Optional[Union[str, List[str]]]

samtranslator/model/connector_profiles/profiles.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,23 @@
790790
}
791791
}
792792
}
793+
},
794+
"AWS::Events::EventBus": {
795+
"Type": "AWS_IAM_ROLE_MANAGED_POLICY",
796+
"Properties": {
797+
"SourcePolicy": true,
798+
"AccessCategories": {
799+
"Write": {
800+
"Statement": [
801+
{
802+
"Effect": "Allow",
803+
"Action": ["events:PutEvents"],
804+
"Resource": ["%{Destination.Arn}"]
805+
}
806+
]
807+
}
808+
}
809+
}
793810
}
794811
},
795812
"AWS::AppSync::GraphQLApi": {

samtranslator/model/eventsources/push.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,11 @@ def add_auth_to_swagger( # noqa: PLR0912, PLR0913
11161116
)
11171117

11181118
auth_scopes = event_auth.get("AuthorizationScopes")
1119+
11191120
if auth_scopes:
11201121
sam_expect(auth_scopes, event_id, "Auth.AuthorizationScopes", is_sam_event=True).to_be_a_list()
1122+
if not method_authorizer:
1123+
raise InvalidEventException(event_id, "AuthorizationScopes works only when Authorizer is set")
11211124

11221125
apikey_required_setting = event_auth.get("ApiKeyRequired")
11231126
apikey_required_setting_is_false = apikey_required_setting is not None and not apikey_required_setting

0 commit comments

Comments
 (0)