How to use the cloudform-types.Fn.If 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() {
        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)
    }
github aws-amplify / amplify-cli / packages / graphql-function-transformer / src / FunctionTransformer.ts View on Github external
role = (name: string, region: string): any => {
    return new IAM.Role({
      RoleName: Fn.If(
        ResourceConstants.CONDITIONS.HasEnvironmentParameter,
        Fn.Join('-', [
          FunctionResourceIDs.FunctionIAMRoleName(name, true), // max of 64. 64-10-26-28 = 0
          Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), // 26
          Fn.Ref(ResourceConstants.PARAMETERS.Env), // 10
        ]),
        Fn.Join('-', [
          FunctionResourceIDs.FunctionIAMRoleName(name, false), // max of 64. 64-26-38 = 0
          Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), // 26
        ])
      ),
      AssumeRolePolicyDocument: {
        Version: '2012-10-17',
        Statement: [
          {
            Effect: 'Allow',
github aws-amplify / amplify-cli / packages / graphql-elasticsearch-transformer / src / resources.ts View on Github external
private joinWithEnv(separator: string, listToJoin: any[]) {
    return Fn.If(
      ResourceConstants.CONDITIONS.HasEnvironmentParameter,
      Fn.Join(separator, [...listToJoin, Fn.Ref(ResourceConstants.PARAMETERS.Env)]),
      Fn.Join(separator, listToJoin)
    );
  }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / resources.ts View on Github external
private dynamoDBTableName(typeName: string): IntrinsicFunction {
    return Fn.If(
      ResourceConstants.CONDITIONS.HasEnvironmentParameter,
      Fn.Join('-', [
        typeName,
        Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
        Fn.Ref(ResourceConstants.PARAMETERS.Env),
      ]),
      Fn.Join('-', [typeName, Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId')])
    );
  }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / resources.ts View on Github external
public makeAppSyncAPI() {
    return new AppSync.GraphQLApi({
      Name: Fn.If(
        ResourceConstants.CONDITIONS.HasEnvironmentParameter,
        Fn.Join('-', [Fn.Ref(ResourceConstants.PARAMETERS.AppSyncApiName), Fn.Ref(ResourceConstants.PARAMETERS.Env)]),
        Fn.Ref(ResourceConstants.PARAMETERS.AppSyncApiName)
      ),
      AuthenticationType: 'API_KEY',
    });
  }
github aws-amplify / amplify-cli / packages / graphql-elasticsearch-transformer / src / resources.ts View on Github external
private domainName() {
        return Fn.If(
            ResourceConstants.CONDITIONS.HasEnvironmentParameter,
            Refs.NoValue,
            Fn.Join(
                '-',
                [
                    'd',
                    Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId')
                ]
            )
        )
    }
github aws-amplify / amplify-cli / packages / graphql-elasticsearch-transformer / src / resources.ts View on Github external
private joinWithEnv(separator: string, listToJoin: any[]) {
        return Fn.If(
            ResourceConstants.CONDITIONS.HasEnvironmentParameter,
            Fn.Join(
                separator,
                [
                    ...listToJoin,
                    Fn.Ref(ResourceConstants.PARAMETERS.Env)
                ]
            ),
            Fn.Join(
                separator,
                listToJoin
            )
        )
    }
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / util / syncUtils.ts View on Github external
export function syncLambdaArnResource({ name, region }: { name: string; region?: string }) {
    const env = 'env;';
    const substitutions = {};
    if (referencesEnv(name)) {
      substitutions[env] = Fn.Ref(ResourceConstants.PARAMETERS.Env);
    }
    return Fn.If(
      ResourceConstants.CONDITIONS.HasEnvironmentParameter,
      Fn.Sub(lambdaArnKey(name, region), substitutions),
      Fn.Sub(lambdaArnKey(removeEnvReference(name), region), {})
    );
  }
  export function lambdaArnKey(name: string, region?: string) {