aws-cloudformation-cognito-identity-pool
aws-cloudformation-cognito-identity-pool copied to clipboard
A Lambda-backed Custom Resource for a Cognito Identity Pool in CloudFormation
❗️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
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
- Ensure you have node.js >= 6 installed (preferably via nvm)
- Install gulp globally (
yarn global add gulp
) - Clone this repository
- Run
yarn
- Create an S3 bucket to hold your Lambda Function (skip this if you already have one)
- Create
config.json
(see below) - Ensure you have the AWS SDK for Node.js configured correctly. Also, set the
AWS_REGION
environment variable. - Run
gulp
this will: - Build the Lambda function and place it in dist.zip
- Upload the function to S3
- Create the CloudFormation Stack
- 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
- 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
, andAWS_REGION
environment variables) - Create your
config.json
- Run
yarn test