How to use the graphql-transformer-common.ResourceConstants.PARAMETERS function in graphql-transformer-common

To help you get started, we’ve selected a few graphql-transformer-common 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-transformers-e2e-tests / src / CloudFormationClient.ts View on Github external
async createStack(template: any, name: string, defParams: any = {}, addAppSyncApiName: boolean = true) {
    const params = [];

    if (addAppSyncApiName === true) {
      params.push({
        ParameterKey: ResourceConstants.PARAMETERS.AppSyncApiName,
        ParameterValue: name,
      });
    }

    for (const key of Object.keys(defParams)) {
      params.push({
        ParameterKey: key,
        ParameterValue: defParams[key],
      });
    }

    // add env info to template
    template.Parameters.env = {
      Type: 'String',
      Description: 'env name',
      Default: 'NONE',
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / util / amplifyUtils.ts View on Github external
const parametersForStack = Object.keys(userDefinedStack.Parameters).reduce(
      (acc, k) => ({
        ...acc,
        [k]: customStackParams[k],
      }),
      {}
    );

    transformStacks[userStack] = userDefinedStack;
    // Split on non alphabetic characters to make a valid resource id.
    const stackResourceId = userStack.split(/[^A-Za-z]/).join('');
    const customNestedStack = new CloudFormation.Stack({
      Parameters: parametersForStack,
      TemplateURL: Fn.Join('/', [
        'https://s3.amazonaws.com',
        Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        'stacks',
        userStack,
      ]),
    }).dependsOn(allResourceIds);
    rootStack.Resources[stackResourceId] = customNestedStack;
  }

  // Update the Root Stack Params since we have added the Child Stack Params if they are missing.
  rootStack.Parameters = updatedParameters;
  return {
    ...transformOutput,
    resolvers: transformResolvers,
    stacks: transformStacks,
  };
}
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public makeParams() {
        return {
            [ResourceConstants.PARAMETERS.AuthCognitoUserPoolId]: new StringParameter({
                Description: 'The id of an existing User Pool to connect. If this is changed, a user pool will not be created for you.',
                Default: ResourceConstants.NONE
            })
        }
    }
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / TransformFormatter.ts View on Github external
public format(ctx: TransformerContext): DeploymentResources {
    ctx.mergeConditions(this.schemaResourceUtil.makeEnvironmentConditions());
    const resolversFunctionsAndSchema = this.collectResolversFunctionsAndSchema(ctx);
    const defaultDependencies = [ResourceConstants.RESOURCES.GraphQLSchemaLogicalID];
    if (ctx.getResource(ResourceConstants.RESOURCES.NoneDataSource)) {
      defaultDependencies.push(ResourceConstants.RESOURCES.NoneDataSource);
    }
    const nestedStacks = splitStack({
      stack: ctx.template,
      stackRules: ctx.getStackMapping(),
      defaultParameterValues: {
        [ResourceConstants.PARAMETERS.AppSyncApiId]: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
      },
      defaultParameterDefinitions: {
        [ResourceConstants.PARAMETERS.AppSyncApiId]: new StringParameter({
          Description: `The id of the AppSync API associated with this project.`,
        }),
      },
      deployment: {
        deploymentBucketParameterName: ResourceConstants.PARAMETERS.S3DeploymentBucket,
        deploymentKeyParameterName: ResourceConstants.PARAMETERS.S3DeploymentRootKey,
      },
      importExportPrefix: Fn.Ref(ResourceConstants.PARAMETERS.AppSyncApiId),
      defaultDependencies,
    });
    return {
      ...nestedStacks,
      ...resolversFunctionsAndSchema,
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
function joinWithEnv(separator: string, listToJoin: any[]) {
    return Fn.If(
      ResourceConstants.CONDITIONS.HasEnvironmentParameter,
      Fn.Join(separator, [...listToJoin, Fn.Ref(ResourceConstants.PARAMETERS.Env)]),
      Fn.Join(separator, listToJoin)
    );
  }
  export function syncLambdaIAMRole({ name, region }: { name: string; region?: string }) {
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-function-transformer / src / FunctionTransformer.ts View on Github external
datasource = (name: string, region: string): any => {
    return new AppSync.DataSource({
      ApiId: Fn.Ref(ResourceConstants.PARAMETERS.AppSyncApiId),
      Name: FunctionResourceIDs.FunctionDataSourceID(name, region),
      Type: 'AWS_LAMBDA',
      ServiceRoleArn: Fn.GetAtt(FunctionResourceIDs.FunctionIAMRoleID(name, region), 'Arn'),
      LambdaConfig: {
        LambdaFunctionArn: lambdaArnResource(name, region),
      },
    }).dependsOn(FunctionResourceIDs.FunctionIAMRoleID(name, region));
  };
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 / SchemaResourceUtil.ts View on Github external
public makeResolverS3RootParams(): Template {
    return {
      Parameters: {
        [ResourceConstants.PARAMETERS.Env]: new StringParameter({
          Description: `The environment name. e.g. Dev, Test, or Production`,
          Default: ResourceConstants.NONE,
        }),
        [ResourceConstants.PARAMETERS.S3DeploymentBucket]: new StringParameter({
          Description: 'The S3 bucket containing all deployment assets for the project.',
        }),
        [ResourceConstants.PARAMETERS.S3DeploymentRootKey]: new StringParameter({
          Description: 'An S3 key relative to the S3DeploymentBucket that points to the root of the deployment directory.',
        }),
      },
    };
  }