Search code examples
amazon-web-servicesterraformterraform-provider-awsamazon-cognito-triggersaws-identitypools

Create cognito sync trigger to lambda function using Terraform


We have identity pools which have event triggers configured to trigger lambda upon sync event from mobile users. Now that we are planning on re-creating the infrastructure using terraform so we can automate stuff, we are facing difficulties in setting up the cognito sync trigger.

We have attempted to use the aws_lambda_permission with source_arn pointing to the identity pool but still the trigger is created which shows that part of the configuration is missing (seen in web console). We are not able to identify the terraform configuration from the documentation for aws_cognito_identity_pool resource which can configure the event for identity pool. We are aware that AWS recommends Appsync in place of cognito sync but this was developed long back and we are not in the idea of migrating any sooner.


Solution

  • That functionality requires a call to the SetCognitoEvents method on the CognitoSync client. Searching through the AWS Terraform Provider source code, I can't find that anywhere. I also don't see anything in the AWS Terraform Provider documentation that would indicate you can configure this feature from Terraform.

    I have to conclude that at this time you cannot configure this feature using Terraform, and since it is a deprecated feature I doubt Terraform will ever add support for it.

    Your best bet may be to use a null provider to call the AWS CLI command aws cognito-sync set-cognito-events.