I'm using the CDK service to generate a CloudFormation template for the AppSync service where authentication used is API Key based.
To note, my API key's validity is 365 days.
The strange thing is that although I don't have any change in CDK code, still whenever I run 'cdk diff' command, it always highlights change in expiry time of the API key as follows:
Stack AppSyncStack-dev
Resources
[~] AWS::AppSync::ApiKey GraphqlAPI/devkeyApiKey GraphqlAPIdevkeyApiKey7B654D8E
└─ [~] Expires
├─ [-] 1652178692
└─ [+] 1652186636
After further triage, I've observed that it is always calculating the API key's expiry time by using a time when 'cdk diff' command is run, and correspondingly it extends the expiry time of the key. To explain, in case I run a 'cdk diff' now, than it will have change set with expiry time as present time of next year as I've 365 day's key validity.
I don't want to change API key's expiry time on each call of 'cdk diff' command.
Any workaround to achieve it? OR any way to ignore a specific field (here expiry time of API key) for 'cdk diff' command?
Environment - Java 8, CDK version 1.113.0 in the pom file of maven