npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@serverless/aws-sdk

v6.1.2

Published

Powerful Serverless Utilities

Downloads

39

Readme

Serverless AWS SDK

The aws sdk + powerful high-level serverless utils.

// require the serverless aws sdk.
const aws = require(`@serverless/aws-sdk`)

// set credentials, as usual.
aws.config.update({
  credentials: { accessKeyId: 'xxx', secretAccessKey: 'xxx' },
  region: 'us-east-1'
})

// use any service, as usual.
const s3 = new aws.S3()

// use some powerful utils. More info below.
const certificate = await aws.utils.deployCertificate(params)

Reference

deployDistributionDomain

Deploys a CloudFront distribution domain by adding the domain to the distribution and deploying the certificate and DNS records.

const params = {
  domain: 'serverless.com',
  distributionId: 'xxx'
}

const {
  certificateArn,
  certificateStatus,
  domainHostedZoneId
} = await aws.utils.deployDistributionDomain(params)

deployCertificate

Deploys a free ACM certificate for the given domain.

const params = {
  domain: 'serverless.com'
}

const { certificateArn, certificateStatus, domainHostedZoneId } = await aws.utils.deployCertificate(
  params
)

deployDistributionDns

Deploys a DNS records for a distribution domain.

const params = {
  domain: 'serverless.com',
  distributionUrl: 'xxx.cloudfront.net'
}

const { domainHostedZoneId } = await aws.utils.deployDistributionDns(params)

addDomainToDistribution

Adds a domain or subdomain to a CloudFront Distribution.

const params = {
  domain: 'serverless.com',
  certificateArn: 'xxx:xxx',
  certificateStatus: 'ISSUED'
}

const { domainHostedZoneId } = await aws.utils.addDomainToDistribution(params)

getDomainHostedZoneId

Fetches the hosted zone id for the given domain.

const params = {
  domain: 'serverless.com'
}

const { domainHostedZoneId } = await aws.utils.getDomainHostedZoneId(params)

deployRole

Updates or creates the given role name with the given service & policy. You can specify an inline policy:

const params = {
  name: 'my-role',
  service: 'lambda.amazonaws.com',
  policy: [
    {
      Effect: 'Allow',
      Action: ['sts:AssumeRole'],
      Resource: '*'
    },
    {
      Effect: 'Allow',
      Action: ['logs:CreateLogGroup', 'logs:CreateLogStream'],
      Resource: '*'
    }
  ]
}
const { roleArn } = await aws.utils.deployRole(params)

Or you can specify the policy as a maanged policy arn string:

const params = {
  name: 'my-role',
  service: 'lambda.amazonaws.com',
  policy: 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
}
const { roleArn } = await aws.utils.deployRole(params)

If you don't specify a policy property, an admin policy will be created by default.

removeRole

Removes the given role and all its attached managed and inline policies.

const params = {
  name: 'my-role'
}

await aws.utils.removeRole(params)

removeRolePolicies

Removes all attached managed and inline policies for the given role.

const params = {
  name: 'my-role'
}

await aws.utils.removeRolePolicies(params)

deployLambda

Updates a lambda if it exists, otherwise creates a new one.

const lambdaParams = {
  lambdaName: 'my-lambda', // required
  roleArn: 'aws:iam:role:arn:xxx', // required
  lambdaSrc: 'path/to/lambda/directory' // required. could also be a buffer of a zip file
  memory: 512 // optional, along with the other lambda config
  vpcConfig: // optional, specify a VPC
    securityGroupIds:
      - sg-xxx
    subnetIds:
      - subnet-xxx
      - subnet-xxx
}

const { lambdaArn, lambdaSize, lambdaSha } = await aws.utils.deployLambda(params)

deployApigDomainDns

Deploys the DNS records for an Api Gateway V2 HTTP custom domain

const lambdaParams = {
  domain: 'serverless.com', // required. The custom domain you'd like to configure.
  apigatewayHostedZoneId: 'qwertyuiop', // required. The regional hosted zone id of the APIG custom domain
  apigatewayDomainName: 'd-qwertyuiop.xxx.com' // required. The regional endpoint of the APIG custom domain
}

const { domainHostedZoneId } = await aws.utils.deployApigDomainDns(params)

deployAppSyncApi

Updates or creates an AppSync API

const deployAppSyncApiParams = {
  apiName: 'my-api',
  apiId: 'xxx' // if provided, updates the API. If not provided, creates a new API
}

const { apiId, apiUrls } = await aws.utils.deployAppSyncApi(params)

deployAppSyncSchema

Updates or creates an AppSync Schema

const deployAppSyncSchemaParams = {
  apiId: 'xxx', // the targeted api id
  schema: '...' // valid graphql schema
}

await aws.utils.deployAppSyncApi(params)

deployAppSyncResolvers

Updates or creates AppSync Resolvers

const deployAppSyncResolversParams = {
  apiId,
  roleName: 'my-role', // name of the role that provides access for these resources to the required resources
  resolvers: {
    Query: {
      getPost: {
        lambda: 'getPost' // name of the lambda function to use as a resolver for the getPost field
      }
    },
    Mutation: {
      putPost: {
        lambda: 'putPost'
      }
    }
  }
}

await aws.utils.deployAppSyncResolvers(params)