How to use the cloudform-types.Fn.Sub 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
{
              Effect: 'Allow',
              Action: ['appsync:GraphQL'],
              Resource: newPolicyResources,
            },
          ],
        },
      });

    for (const resource of resources) {
      // We always have 2 parts, no need to check
      const resourceParts = resource.split('/');

      if (resourceParts[1] !== 'null') {
        policyResources.push(
          Fn.Sub('arn:aws:appsync:${AWS::Region}:${AWS::AccountId}:apis/${apiId}/types/${typeName}/fields/${fieldName}', {
            apiId: {
              'Fn::GetAtt': ['GraphQLAPI', 'ApiId'],
            },
            typeName: resourceParts[0],
            fieldName: resourceParts[1],
          })
        );

        resourceSize += RESOURCE_OVERHEAD + resourceParts[0].length + resourceParts[1].length;
      } else {
        policyResources.push(
          Fn.Sub('arn:aws:appsync:${AWS::Region}:${AWS::AccountId}:apis/${apiId}/types/${typeName}/*', {
            apiId: {
              'Fn::GetAtt': ['GraphQLAPI', 'ApiId'],
            },
            typeName: resourceParts[0],
github aws-amplify / amplify-cli / packages / graphql-function-transformer / src / lambdaArns.ts View on Github external
export function lambdaArnResource(name: string, region?: string) {
  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), {})
  );
}
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / util / syncUtils.ts View on Github external
Version: '2012-10-17',
            Statement: [
              {
                Effect: 'Allow',
                Action: [
                  'dynamodb:BatchGetItem',
                  'dynamodb:BatchWriteItem',
                  'dynamodb:PutItem',
                  'dynamodb:DeleteItem',
                  'dynamodb:GetItem',
                  'dynamodb:Scan',
                  'dynamodb:Query',
                  'dynamodb:UpdateItem',
                ],
                Resource: [
                  Fn.Sub('arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}', {
                    tablename: SyncResourceIDs.syncTableName,
                  }),
                  Fn.Sub('arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}/*', {
                    tablename: SyncResourceIDs.syncTableName,
                  }),
                ],
              },
            ],
          },
        }),
      ],
    });
  }
  export function syncLambdaArnResource({ name, region }: { name: string; region?: string }) {
github aws-amplify / amplify-cli / packages / graphql-http-transformer / src / resources.ts View on Github external
private replaceEnv(value: string): Value {
    if (!this.referencesEnv(value)) {
      return value;
    }

    return Fn.Sub(value, {
      env: Fn.Ref(ResourceConstants.PARAMETERS.Env),
    });
  }
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / util / syncUtils.ts View on Github external
Effect: 'Allow',
                Action: [
                  'dynamodb:BatchGetItem',
                  'dynamodb:BatchWriteItem',
                  'dynamodb:PutItem',
                  'dynamodb:DeleteItem',
                  'dynamodb:GetItem',
                  'dynamodb:Scan',
                  'dynamodb:Query',
                  'dynamodb:UpdateItem',
                ],
                Resource: [
                  Fn.Sub('arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}', {
                    tablename: SyncResourceIDs.syncTableName,
                  }),
                  Fn.Sub('arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}/*', {
                    tablename: SyncResourceIDs.syncTableName,
                  }),
                ],
              },
            ],
          },
        }),
      ],
    });
  }
  export function syncLambdaArnResource({ name, region }: { name: string; region?: string }) {
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) {
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) {
github aws-amplify / amplify-cli / packages / graphql-relational-schema-transformer / src / RelationalDBResolverGenerator.ts View on Github external
const resTemplate = print(ref('utils.toJson($utils.rds.toJsonObject($ctx.result)[0])'));

    fs.writeFileSync(`${this.resolverFilePath}/${reqFileName}`, reqTemplate, 'utf8');
    fs.writeFileSync(`${this.resolverFilePath}/${resFileName}`, resTemplate, 'utf8');

    let resolver = new AppSync.Resolver({
      ApiId: Fn.Ref(ResourceConstants.PARAMETERS.AppSyncApiId),
      DataSourceName: Fn.GetAtt(ResourceConstants.RESOURCES.RelationalDatabaseDataSource, 'Name'),
      TypeName: queryTypeName,
      FieldName: fieldName,
      RequestMappingTemplateS3Location: Fn.Sub(s3BaseUrl, {
        [ResourceConstants.PARAMETERS.S3DeploymentBucket]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        [ResourceConstants.PARAMETERS.S3DeploymentRootKey]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        [resolverFileName]: reqFileName,
      }),
      ResponseMappingTemplateS3Location: Fn.Sub(s3BaseUrl, {
        [ResourceConstants.PARAMETERS.S3DeploymentBucket]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        [ResourceConstants.PARAMETERS.S3DeploymentRootKey]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        [resolverFileName]: resFileName,
      }),
    }).dependsOn([ResourceConstants.RESOURCES.RelationalDatabaseDataSource]);

    return resolver;
  }
}
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / util / SchemaResourceUtil.ts View on Github external
public updateResolverResource(resource: Resource) {
    resource.Properties.RequestMappingTemplateS3Location = Fn.Sub(
      's3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/${ResolverFileName}',
      {
        S3DeploymentBucket: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        S3DeploymentRootKey: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        ResolverFileName: Fn.Join('.', [resource.Properties.TypeName, resource.Properties.FieldName, 'req', 'vtl']),
      }
    );
    resource.Properties.ResponseMappingTemplateS3Location = Fn.Sub(
      's3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/${ResolverFileName}',
      {
        S3DeploymentBucket: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        S3DeploymentRootKey: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        ResolverFileName: Fn.Join('.', [resource.Properties.TypeName, resource.Properties.FieldName, 'res', 'vtl']),
      }
    );
    delete resource.Properties.RequestMappingTemplate;
    delete resource.Properties.ResponseMappingTemplate;
    return resource;
  }