Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(publisher-s3): Add sessionToken and change default fallback #2984

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/publisher/s3/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ export interface PublisherS3Config {
/**
* Your AWS Access Key ID
*
* Falls back to the AWS_ACCESS_KEY_ID environment variable if not provided
* Falls back to the the default credential provider chain if not
* provided
*/
accessKeyId?: string;
/**
* The secret for your AWS Access Key
*
* Falls back to the AWS_SECRET_ACCESS_KEY environment variable if not
* Falls back to the the default credential provider chain if not
* provided
*/
secretAccessKey?: string;
/**
* The session token for your AWS Access Key
*
* Falls back to the the default credential provider chain if not
* provided
*/
sessionToken?: string;
/**
* The name of the S3 bucket to upload artifacts to
*/
Expand Down
7 changes: 4 additions & 3 deletions packages/publisher/s3/src/PublisherS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ export default class PublisherS3 extends PublisherBase<PublisherS3Config> {
}

generateCredentials(): Credentials | undefined {
const accessKeyId = this.config.accessKeyId || process.env.AWS_ACCESS_KEY_ID;
const secretAccessKey = this.config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY;
const accessKeyId = this.config.accessKeyId;
const secretAccessKey = this.config.secretAccessKey;
Comment on lines +93 to +94
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Could we re-add the process.env fallbacks here, so that these are included if they're not in the config (CI could be a use case here)?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This GitHub Action does use environment variables! https://github.com/aws-actions/configure-aws-credentials

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VerteDinde if the credentials are not in the config and present in the process.env, the SDK will use them without needing to pass them explicitly.

THis is the recommended way. See doc

const sessionToken = this.config.sessionToken;

if (accessKeyId && secretAccessKey) {
return { accessKeyId, secretAccessKey };
return { accessKeyId, secretAccessKey, sessionToken };
}

return undefined;
Expand Down