Skip to content
This repository has been archived by the owner on Dec 11, 2017. It is now read-only.

A Lambda-backed Custom Resource for a Cognito Identity Pool in CloudFormation

License

Notifications You must be signed in to change notification settings

binoculars/aws-cloudformation-cognito-identity-pool

Repository files navigation

❗️DEPRECATED as of 2017-04-28. Please use AWS::Cognito::IdentityPool

AWS CloudFormation Cognito Identity Pool

An AWS Lambda-backed Custom Resource for CRUD operations on Cognito Identity Pools

Codacy Badge Dependency Status devDependency Status Code Climate Test Coverage Issue Count Known Vulnerabilities Greenkeeper badge bitHound Code

  • Master: CircleCI
  • Develop: CircleCI

Background

Cognito Identity Pools are not currently supported within CloudFormation templates. However, CloudFormation provides extensibility via Custom Resources, which enable Create/Update/Delete operations. This is meant to replace having to manually create Cognito Identity Pools manually via the CLI or web console.

See the related blog post for more information.

Quick Start

  1. Ensure you have node.js >= 6 installed (preferably via nvm)
  2. Install gulp globally (yarn global add gulp)
  3. Clone this repository
  4. Run yarn
  5. Create an S3 bucket to hold your Lambda Function (skip this if you already have one)
  6. Create config.json (see below)
  7. Ensure you have the AWS SDK for Node.js configured correctly. Also, set the AWS_REGION environment variable.
  8. Run gulp this will:
  9. Build the Lambda function and place it in dist.zip
  10. Upload the function to S3
  11. Create the CloudFormation Stack
  12. Create your IAM Role Policy(ies). Examples are provided in cloudformation-role-policies-example.json, which provides managed policies that are attached to the IAM roles. This is necessary for your users to be able to use their credentials to do anything.

Example config.json

Create a config.json file. See The AWS-SDK for JavaScript docs on CognitoIdentity for options, or run aws cloudformation get-template-summary --template-body file:///path/to/cloudformation.json

{
	"IdentityPoolName": "IdentityPoolName",
	"AllowUnauthenticatedIdentities": false,
	"LambdaS3Bucket": "bucket-name",
	"LambdaS3Key": "CloudFormation-CustomResource-CognitoIdentityPool.zip",
	"DeveloperProviderName": "com.site"
}

All non-string values will be stringified for the CloudFormation template. If you're going to use the template directly (instead of using gulp), keep this in mind.

Testing

  1. Configure your environment
  • Run yarn install (yarn)
  • Create your Lambda S3 Bucket
  • Configure the AWS SDK for Node.js (or just set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION environment variables)
  • Create your config.json
  1. Run yarn test