-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(appsync): add authenticationConfig to HttpDataSource, fixes #9934 #9971
Changes from 1 commit
1467be2
eab93cf
a594a35
dbbe4bf
4500ce8
ad51794
b24c6f3
442828b
8c68f3c
beb0269
b289be5
f8879e6
26fe550
e6250b2
5b574c6
97ab65a
08b42d9
48ee5a9
9be1c7c
f1a1145
5e7d3af
3268ff4
e33d77c
392bf12
7f608ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,35 @@ export class DynamoDbDataSource extends BackedDataSource { | |
} | ||
} | ||
|
||
/** | ||
* The authorization config in case the HTTP endpoint requires authorization | ||
*/ | ||
export interface HttpDataSourceAuthorizationConfig { | ||
/** | ||
* The authorization type required by the HTTP endpoint | ||
*/ | ||
readonly authorizationType: 'AWS_IAM'; | ||
/** | ||
* The IAM configuration required by the HTTP endpoint | ||
*/ | ||
readonly awsIamConfig: HttpDataSourceIamConfig; | ||
} | ||
|
||
/** | ||
* The IAM configuration required by the HTTP endpoint | ||
*/ | ||
export interface HttpDataSourceIamConfig { | ||
/** | ||
* The signing region for AWS IAM authorization | ||
*/ | ||
readonly signingRegion: string; | ||
|
||
/** | ||
* The signing service name for AWS IAM authorization | ||
*/ | ||
readonly signingServiceName: string; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the authorization type is always going to AWS_IAM as seen by these docs, I think it might be best to just expose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BryanPan342 I have a question. JSII does not allow nested objects directly. I got a linting error when I tried to implement like below.
export interface AwsIamConfig {
/**
* The authorization type required by the HTTP endpoint
*/
readonly authorizationType: 'AWS_IAM';
/**
* The IAM configuration required by the HTTP endpoint
*/
readonly awsIamConfig: {
/**
* The signing region for AWS IAM authorization
*/
readonly signingRegion: string;
/**
* The signing service name for AWS IAM authorization
*/
readonly signingServiceName: string;
}
} Do you know the better way to integrate it? I still code separately. But I tried to along with Cfn definition.
haruharuharuby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Properties for an AppSync http datasource | ||
*/ | ||
|
@@ -211,6 +240,7 @@ export interface HttpDataSourceProps extends BaseDataSourceProps { | |
* The http endpoint | ||
*/ | ||
readonly endpoint: string; | ||
readonly authorizationConfig?: HttpDataSourceAuthorizationConfig; | ||
haruharuharuby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
|
@@ -221,6 +251,7 @@ export class HttpDataSource extends BaseDataSource { | |
super(scope, id, props, { | ||
httpConfig: { | ||
endpoint: props.endpoint, | ||
authorizationConfig: props.authorizationConfig | ||
}, | ||
type: 'HTTP', | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,35 @@ describe('Http Data Source configuration', () => { | |
}); | ||
}); | ||
|
||
test('appsync configures name, authorizationConfig correctly', () => { | ||
// WHEN | ||
api.addHttpDataSource('ds', endpoint, { | ||
name: 'custom', | ||
description: 'custom description', | ||
authorizationConfig: { | ||
authorizationType: 'AWS_IAM', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this line necessary? the authorizationType is fixed to AWS_IAM no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, It true. AWS_IAM takes only a single value. I remove it. |
||
awsIamConfig: { | ||
signingRegion: 'us-east-1', | ||
signingServiceName: 'states' | ||
} | ||
BryanPan342 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}); | ||
|
||
// THEN | ||
expect(stack).toHaveResourceLike('AWS::AppSync::DataSource', { | ||
Type: 'HTTP', | ||
Name: 'custom', | ||
Description: 'custom description', | ||
AuthorizationConfig: { | ||
authorizationType: 'AWS_IAM', | ||
awsIamConfig: { | ||
signingRegion: 'us-east-1', | ||
signingServiceName: 'states' | ||
} | ||
} | ||
}); | ||
}) | ||
|
||
test('appsync errors when creating multiple http data sources with no configuration', () => { | ||
// THEN | ||
expect(() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this field necessary if it's fixed?
could we just make the interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the authorizationType removes from the caller. Building it Constructor in DataSource.