How to use the @mapbox/cloudfriend.accountId function in @mapbox/cloudfriend

To help you get started, we’ve selected a few @mapbox/cloudfriend 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 mapbox / DEPRECATED-lambda-cfn / lib / cfn.js View on Github external
throw new Error('More than 60 parameters specified');
  }

  // since build functions may create their own parameters outside of
  // the buildParameters step, this is called after all functions
  // have been run, gathers all parameters and injects them into the lambda
  // environment configuration
  // TODO: is this possible when embedding?

  if (!functionTemplate.Variables) {
    functionTemplate.Variables = {};
  }
  // make some global env vars available
  functionTemplate.Variables.StackName = cf.stackName;
  functionTemplate.Variables.Region = cf.region;
  functionTemplate.Variables.AccountId = cf.accountId;
  functionTemplate.Variables.StackId = cf.stackId;

  for (let param in functionTemplate.Parameters) {
    functionTemplate.Variables[param] = cf.ref(param);
  }

  if (!functionTemplate.Resources) {
    functionTemplate.Resources[options.name] = {};
  }

  functionTemplate.Resources[options.name].Properties.Environment.Variables = functionTemplate.Variables;

  // Variables object is not valid CFN
  delete functionTemplate.Variables;

  // compile any additional built-in policy objects into role
github mapbox / ecs-watchbot / lib / template.js View on Github external
PolicyName: cf.join([cf.stackName, '-user-defined-worker']),
      PolicyDocument: {
        Statement: options.permissions
      }
    });

  if (options.reduce) {
    const tableName = cf.join('-', [cf.stackName, prefixed('-progress')]);
    const tableThroughput = {
      readCapacityUnits: options.readCapacityUnits,
      writeCapacityUnits: options.writeCapacityUnits
    };

    Resources[prefixed('ProgressTable')] = table(tableName, tableThroughput);

    const tableArn = cf.join(['arn:aws:dynamodb:', cf.region, ':', cf.accountId, ':table/', cf.ref(prefixed('ProgressTable'))]);

    Resources[prefixed('ProgressTablePermission')] = {
      Type: 'AWS::IAM::Policy',
      Properties: {
        Roles: [cf.ref(prefixed('Role'))],
        PolicyName: 'watchbot-progress',
        PolicyDocument: {
          Statement: [
            {
              Action: [
                'dynamodb:GetItem',
                'dynamodb:PutItem',
                'dynamodb:UpdateItem'
              ],
              Effect: 'Allow',
              Resource: tableArn
github mapbox / stork / cloudformation / stork.template.js View on Github external
Role: cf.getAtt('TriggerLambdaRole', 'Arn'),
      Code: {
        S3Bucket: cf.sub('${OutputBucketPrefix}-${AWS::Region}'),
        S3Key: cf.sub('${OutputKeyPrefix}/stork/${GitSha}.zip')
      },
      Handler: 'lambda.trigger',
      Runtime: 'nodejs6.10',
      Timeout: 300,
      MemorySize: 512,
      Environment: {
        Variables: {
          GITHUB_APP_ID: cf.ref('GithubAppId'),
          GITHUB_APP_INSTALLATION_ID: cf.ref('GithubAppInstallationId'),
          GITHUB_APP_PRIVATE_KEY: cf.ref('GithubAppPrivateKey'),
          NPM_ACCESS_TOKEN: cf.ref('NpmAccessToken'),
          AWS_ACCOUNT_ID: cf.accountId,
          S3_BUCKET: cf.sub('${OutputBucketPrefix}-${AWS::Region}'),
          S3_PREFIX: cf.ref('OutputKeyPrefix'),
          PROJECT_ROLE: cf.getAtt('ProjectRole', 'Arn'),
          STATUS_FUNCTION: cf.getAtt('StatusLambda', 'Arn')
        }
      }
    }
  },
  TriggerLambdaErrorAlarm: {
    Type: 'AWS::CloudWatch::Alarm',
    Properties: {
      AlarmName: cf.sub('${AWS::StackName}-trigger-function-errors'),
      Period: 60,
      EvaluationPeriods: 1,
      Statistic: 'Sum',
      Threshold: 0,