How to use the cloudform-types.AppSync.ApiKey function in cloudform-types

To help you get started, we’ve selected a few cloudform-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public makeAppSyncApiKey(apiKeyConfig: Transformer.ApiKeyConfig) {
    let expirationDays = 7;
    if (apiKeyConfig && apiKeyConfig.apiKeyExpirationDays) {
      expirationDays = apiKeyConfig.apiKeyExpirationDays;
    }
    const expirationDateInSeconds = 60 /* s */ * 60 /* m */ * 24 /* h */ * expirationDays; /* d */
    const nowEpochTime = Math.floor(Date.now() / 1000);
    return new AppSync.ApiKey({
      ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
      Description: apiKeyConfig && apiKeyConfig.description ? apiKeyConfig.description : undefined,
      Expires: Fn.If(
        ResourceConstants.CONDITIONS.APIKeyExpirationEpochIsPositive,
        Fn.Ref(ResourceConstants.PARAMETERS.APIKeyExpirationEpoch),
        nowEpochTime + expirationDateInSeconds
      ),
    }).condition(ResourceConstants.CONDITIONS.ShouldCreateAPIKey);
  }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public makeAppSyncApiKey() {
        const oneWeekFromNowInSeconds = 60 /* s */ * 60 /* m */ * 24 /* h */ * 7 /* d */
        const nowEpochTime = Math.floor(Date.now() / 1000)
        return new AppSync.ApiKey({
            ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
            Expires: Fn.If(
                ResourceConstants.CONDITIONS.APIKeyExpirationEpochIsPositive,
                Fn.Ref(ResourceConstants.PARAMETERS.APIKeyExpirationEpoch),
                nowEpochTime + oneWeekFromNowInSeconds
            ),
        }).condition(ResourceConstants.CONDITIONS.ShouldCreateAPIKey)
    }