今日已更新 396 条资讯 | 累计 20866 条内容
关于我们

Connecting AWS Account with Cypress Automation: A Simple STS Connection Test

Sehani Chathurangi 2026年07月17日 20:42 0 次阅读 来源:Dev.to

When building Cypress automation that interacts with AWS services, the first step is verifying that your test framework can successfully authenticate and communicate with your AWS account. In this article, you'll learn how to connect Cypress to AWS and perform a simple authentication test using AWS Security Token Service (STS) and the GetCallerIdentity API. This approach helps confirm that: AWS credentials are correctly configured. Cypress can invoke AWS SDK operations through Node.js tasks. The automation environment is connected to the expected AWS account. Establishing this connection first provides a solid foundation before automating interactions with services such as AWS Lambda, Amazon S3, Amazon DynamoDB, Amazon SNS, or Amazon SQS. Prerequisites Before getting started, ensure you have: Node.js installed A Cypress project Valid AWS credentials: AWS Access Key ID AWS Secret Access Key AWS Session Token (if using temporary credentials) AWS Region Note:If you're running Cypress in an AWS environment (such as AWS CodeBuild, an EC2 instance with an IAM role, or GitHub Actions using OpenID Connect), you may not need to provide credentials manually. The AWS SDK can automatically retrieve credentials from the execution environment. Step 1: Install the AWS SDK Install the AWS STS client package: npm install @aws-sdk/client-sts For this connectivity test, we only need the AWS Security Token Service (STS) client. The package provides: STSClient – Creates a client for communicating with AWS STS. GetCallerIdentityCommand – Returns details about the authenticated AWS identity associated with the configured credentials. Step 2: Configure AWS Credentials For local development, create or update your cypress.env.json file. { "AWS_ACCESS_KEY_ID" : "" , "AWS_SECRET_ACCESS_KEY" : "" , "AWS_SESSION_TOKEN" : "" , "AWS_REGION" : "" } Populate the file with your AWS credentials. Example: { "AWS_ACCESS_KEY_ID" : "your-access-key" , "AWS_SECRET_ACCESS_KEY" : "your-secret-key" , "AWS_SES

本文内容来源于互联网,版权归原作者所有
查看原文