Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,15 @@ export class GraphQLApi extends Construct {
* underlying CFN schema resource
*/
public readonly schema: CfnGraphQLSchema;
/**
* the configured API key, if present
*/
public get apiKey(): string | undefined {
return this._apiKey;
}

private api: CfnGraphQLApi;
private _apiKey?: string;

constructor(scope: Construct, id: string, props: GraphQLApiProps) {
super(scope, id);
Expand Down Expand Up @@ -325,11 +332,12 @@ export class GraphQLApi extends Construct {
}
expires = Math.round(expires / 1000);
}
new CfnApiKey(this, `${akConfig.apiKeyDesc || ''}ApiKey`, {
const key = new CfnApiKey(this, `${akConfig.apiKeyDesc || ''}ApiKey`, {
expires,
description: akConfig.apiKeyDesc,
apiId: this.apiId,
});
this._apiKey = key.attrApiKey;
return { authenticationType: 'API_KEY' };
}
}
Expand Down