Invalid Identity Pool Configuration Error with AWS Amplify and Cognito

Description:

I’m developing a React application using AWS Amplify, which integrates with AWS Cognito for user authentication and AWS AppSync for GraphQL APIs. My backend is built using the CloudFormation Serverless framework in Node.js, and my GraphQL API supports two authentication modes: Cognito and IAM.

Here I am attempting to allow unauthorized guest users to access certain API operations using IAM authentication, while authenticated users use Cognito.

Problem:

When attempting to fetch data from my GraphQL endpoint using generateClient from AWS Amplify’s API module with IAM authMode for unauthorized access, I encounter the following error:

Invalid identity pool configuration. Check assigned IAM roles for this pool.
InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool.

Details:

  • Amplify Configuration (src/index.js) :

    Amplify.configure({
      Auth: {
        Cognito: {
          userPoolId: "****", 
          userPoolClientId: "****", 
          identityPoolId: "****", 
          allowGuestAccess: true,
        },
      },
      API: {
        GraphQL: {
          endpoint: "https://****.appsync-api.us-east-1.amazonaws.com/graphql", 
          region: "us-east-1",
          defaultAuthMode: "userPool",
        },
      },
    });
    
    

    Here I am using the graphql API to fetch a book using its id in src/App.js:

    Although the default authorization mode is cognito user pool , I am using identity pool with an IAM Role for unauthorised users that would allow them to access the graphql API.

    import React from "react";
    import { generateClient } from "aws-amplify/api";
    import { Authenticator } from "@aws-amplify/ui-react";
    import { getBookById } from "./graphql/queries";
    import "@aws-amplify/ui-react/styles.css";
    
    export default function App() {
      const [book, setBook] = React.useState({}); 
      const getBook = async () => {
        const client = generateClient("bookstore");
        const bookId = "358748d6-f047-4***-8b**-e********";
        const book = await client.graphql({
          query: getBookById,
          variables: { id: bookId },
          authMode: "identityPool",
        });
        setBook(book.data.getBookById);
      };
      return (
        <div style={{ margin: "20px" }}>
          <!--code to display book details-->
        </div>
      );
    }
    
    

    Issue Context:

    • This setup is intended to allow guest users to access certain API queries using IAM authentication (including Amazon Cognito Identity Pool.

    • Queries on AWS console for guest users using IAM are successful, indicating the IAM roles are correctly configured.

Request for Help: I’m seeking guidance on how to resolve this InvalidIdentityPoolConfigurationException error when using IAM authMode with generateClient in AWS Amplify for unauthorized guest users. Any insights or alternative approaches would be greatly appreciated!

  • Troubleshooting Efforts:

    • Cleared browser cache and checked AWS IAM roles.

    • Verified AWS Amplify and Cognito configurations are correct.

    • Explored AWS Amplify and AppSync documentation but found no specific guidance for this scenario.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật