-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(appsync): allow user to configure log retention time (#21418)
This pull request implements a feature that allows users to configure the log retention period for App Sync logs. AWS AppSync doesn't allow users to use user-defined log groups, leaving the option to create the log group for the user and set the retention time accordingly. Fortunately, the service always creates its log groups according to a pre-defined naming convention. > The log group is named following the /aws/appsync/apis/{graphql_api_id} format ref. https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html At the same time, AWS CDK provides a stable [construct](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogRetention.html) to set log retention times for any log group. Thus, it is completely unnecessary to force every user to learn this detail when it can be abstracted to the construct creating the resource for them – that is what this pull request aims to do. This is the continuation of work done in #20536 – this time with documentation and integration test 😄 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
3853728
commit a2bb263
Showing
15 changed files
with
2,326 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { join } from 'path'; | ||
import { RetentionDays } from '@aws-cdk/aws-logs'; | ||
import { App, Stack } from '@aws-cdk/core'; | ||
import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests'; | ||
import { GraphqlApi, LogConfig, Schema } from '../lib'; | ||
|
||
const app = new App(); | ||
const stack = new Stack(app, 'AppSyncIntegLogRetention'); | ||
|
||
|
||
const retentionTime = RetentionDays.ONE_WEEK; | ||
const logConfig: LogConfig = { | ||
retention: retentionTime, | ||
}; | ||
|
||
const api = new GraphqlApi(stack, 'GraphqlApi', { | ||
authorizationConfig: {}, | ||
name: 'IntegLogRetention', | ||
schema: Schema.fromAsset(join(__dirname, 'appsync.test.graphql')), | ||
logConfig, | ||
}); | ||
|
||
const integ = new IntegTest(app, 'Integ', { testCases: [stack] }); | ||
|
||
const describe = integ.assertions.awsApiCall('CloudWatchLogs', | ||
'describeLogGroups', | ||
{ | ||
logGroupNamePrefix: api.logGroup.logGroupName, | ||
}); | ||
|
||
describe.expect(ExpectedResult.objectLike({ | ||
logGroups: [ | ||
{ | ||
logGroupName: api.logGroup.logGroupName, | ||
retentionInDays: retentionTime, | ||
}, | ||
], | ||
})); | ||
|
||
app.synth(); |
Oops, something went wrong.