An application that uses AWS Cognito for Authentication, API Gateway, Lambda and S3.
- AWS Account
- Terraform
- Node.js: Version 20 or higher, this is required to build the Angular application.
- Google Account for OAuth: Create a project in Google Cloud Console and enable Google+ API. Create OAuth 2.0 Client ID and download the credentials.
- Domain Name: A domain name that you own. This is required for the website to be hosted on Cloudfront and for Google OAuth.
- Route53 Hosted Zone: A hosted zone in Route53 for the domain name.
- AWS Certificate Manager: A certificate for the domain name.
git clone <repo-url>cd webapp
npm install
npm run build:prod
cd ..Create a file named terraform.tfvars in the terraform directory with the following content.
domain_name = "example.com"
cognito_google_client_id = "XXXXXXXX.apps.googleusercontent.com"
cognito_google_client_secret = "XXXXXXXX
certificate_arn = "arn:aws:acm:us-east-1:XXXXXXXX:certificate/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
cd terraform
terraform init
terraform apply --var-file=terraform.tfvars -auto-approveUpdate the webapp/src/app/aws-exports.ts file with the terraform output user_pool_id, user_pool_client_id. Build the webapp again. Run terraform apply again to update the S3 bucket with the new webapp build.
Read the Cloudfront URL from the terraform output and access the application.
terraform destroy --var-file=terraform.tfvars -auto-approve- DynamoDB events table time to live configuration.
- Check if there is a better way to upload the files to S3 instead of uploading first the html files then the js files and finally the css files.
aws --region=us-east-1 cognito-identity get-id --identity-pool-id us-east-1:fd8ee126-c036-44f9-85c7-ec92eca4e315
--logins "cognito-idp.us-east-1.amazonaws.com/us-east-1_swu99Czgc="
aws --region=us-east-1 cognito-identity get-credentials-for-identity --identity-id us-east-1:e33519eb-7cfe-cc02-495e-3e53c6ca899a
--logins "cognito-idp.us-east-1.amazonaws.com/us-east-1_swu99Czgc=eyJraWQiOiJzUGVkWmxoUEphZElCZUxzSlducHAwcFBRQmhrNEU3NzJ5ejRPRWJrd2RNPSIsImFsZyI6IlJTMjU2In0.eyJhdF9oYXNoIjoiZVB1d3lBTlJNQTBsNkZpVUtsQzNfQSIsInN1YiI6ImU0NjhmNDE4LTMwZjEtNzBlMi0yODdmLWQyNG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