When specifying the attribute "expires" for apiKeyConfig, the rendered cloudformation gets a value of null.
const api = new GraphQLApi(this, 'api', {
name: getResourceName('graphql'),
authorizationConfig: {
defaultAuthorization: {
authorizationType: AuthorizationType.API_KEY,
apiKeyConfig: {
name: "api-key",
description: "api-key",
expires: "1614164998"
}
},
schemaDefinitionFile: 'schema.graphql',
});
Synth gives:
apiapikeyApiKeyXXXXXX:
Type: AWS::AppSync::ApiKey
Properties:
ApiId:
Fn::GetAtt:
- apiCXXXXXX
- ApiId
Description: api-key
Expires: null
This is :bug: Bug Report
According to the definition:
export interface ApiKeyConfig {
...
/**
* The time from creation time after which the API key expires, using RFC3339 representation.
* It must be a minimum of 1 day and a maximum of 365 days from date of creation.
* Rounded down to the nearest hour.
* @default - 7 days from creation time
*/
readonly expires?: string;
}
You should set expires like 2020-12-31T23:30:00Z
Use new Date(...).toISOString() or any other date/time library.
But in fact, it is also prone to errors and needs to be changed in a different way.
export interface ApiKeyConfig {
...
/**
* The duration from creation time after which the API key expires.
* It must be a minimum of 1 day and a maximum of 365 days from date of creation.
* Rounded down to the nearest hour.
* @default - cdk.Duration.days(7)
*/
readonly expiresAfter?: cdk.Duration;
}
Any good idea?
What about using kind of Expires?
{
...,
expires: '2020-12-31T23:30:00Z'
}
expires: Expires.atDate(new Date('2020-12-31T23:30:00Z'))expires: Expires.after(cdk.Duration.months(6))expires: Expires.fromTimestamp(1614164998000)expires: Expires.fromString('2020-12-31T23:30:00Z')I hope the things below would be promoted to @aws-cdk/core, as well as Duration
@nija-at @jogold
Most helpful comment
What about using kind of
Expires?AS-IS
TO-BE
expires: Expires.atDate(new Date('2020-12-31T23:30:00Z'))expires: Expires.after(cdk.Duration.months(6))expires: Expires.fromTimestamp(1614164998000)expires: Expires.fromString('2020-12-31T23:30:00Z')References
I hope the things below would be promoted to
@aws-cdk/core, as well asDuration@nija-at @jogold
Expires
https://github.com/aws/aws-cdk/blob/254556d875f9a378ac98d5c3193306250068d3c9/packages/%40aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts#L318-L344
Schedule
https://github.com/aws/aws-cdk/blob/254556d875f9a378ac98d5c3193306250068d3c9/packages/%40aws-cdk/aws-applicationautoscaling/lib/schedule.ts#L3-L64