{"id":15979269,"url":"https://github.com/perry-mitchell/aws-get-credentials","last_synced_at":"2025-05-07T06:43:50.878Z","repository":{"id":20142663,"uuid":"88971343","full_name":"perry-mitchell/aws-get-credentials","owner":"perry-mitchell","description":"Create an AWS credentials instance from local credentials","archived":false,"fork":false,"pushed_at":"2023-04-24T23:25:36.000Z","size":199,"stargazers_count":3,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T11:54:53.652Z","etag":null,"topics":["amazon-web-services","aws","aws-credentials","aws-profile","aws-sdk"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/perry-mitchell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-21T10:12:08.000Z","updated_at":"2024-05-12T12:48:28.000Z","dependencies_parsed_at":"2025-03-10T21:40:57.127Z","dependency_job_id":null,"html_url":"https://github.com/perry-mitchell/aws-get-credentials","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Faws-get-credentials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Faws-get-credentials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Faws-get-credentials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Faws-get-credentials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perry-mitchell","download_url":"https://codeload.github.com/perry-mitchell/aws-get-credentials/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831176,"owners_count":21810779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-web-services","aws","aws-credentials","aws-profile","aws-sdk"],"created_at":"2024-10-07T23:41:55.169Z","updated_at":"2025-05-07T06:43:50.860Z","avatar_url":"https://github.com/perry-mitchell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws-get-credentials\n\u003e Create an AWS credentials instance from local credentials\n\n[![npm version](https://badge.fury.io/js/aws-get-credentials.svg)](https://www.npmjs.com/package/aws-get-credentials) [![Build Status](https://travis-ci.org/perry-mitchell/aws-get-credentials.svg?branch=master)](https://travis-ci.org/perry-mitchell/aws-get-credentials)\n\n## About\n\nFetch a credentials instance from your local machine using a very simple fetcher method.\n\nAvoid hardcoding and commiting secure information by using [AWS' credentials file](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) for configuration. Some AWS client libraries automatically read this file, but some do not. **aws-get-credentials** provides a quick and easy method to retrieve a credential file's config.\n\n## Usage\n\nThe `aws-get-credentials` module exports two methods:\n\n * `getAWSCredentials` - Fetch an AWS `Credentials` instance from local configuration\n * `getAWSProfiles` - Get an array of profile names available\n\nCheck out the [API documentation](API.md) for more information.\n\n### getAWSCredentials\n\nThe method `getAWSCredentials` takes two parameters:\n\n```javascript\ngetAWSCredentials(\n    optionalProfileOverride,\n    optionalPathOverride,\n    useEnvironmentVariables = false\n) // =\u003e Promise.\u003cAWS.Credentials\u003e\n```\n\n`optionalProfileOverride` is an optional override for the profile to use (defaults to an environment variable `AWS_DEFAULT_PROFILE` first, then \"default\" lastly). `optionalPathOverride` is an optional override for the path to the credentials file (defaults to an environment variable `AWS_CREDENTIALS_PATH` first, and then `~/.aws/credentials` lastly).\n\nProviding `true` for the 3rd parameter, \"useEnvironmentVariables\", tells `getAWSCredentials` to return a `Credentials` instance using the available environment variables _instead_ of trying to read from the local credentials file.\n\n#### Example\n\nFirstly, import the function:\n\n```javascript\nconst { getAWSCredentials } = require(\"aws-get-credentials\");\n```\n\nThen use its output (promise):\n\n```javascript\nconst s3 = require(\"s3\"); // example library\n\ngetAWSCredentials(\"production\")\n    .then(function(credentials) {\n        const s3Client = s3.createClient({\n            s3Options: {\n                credentials\n            }\n        });\n        const syncOptions = {};\n        const uploader = s3Client.uploadDir(syncOptions);\n        return new Promise(function(resolve, reject) {\n            uploader.on(\"error\", reject);\n            uploader.on(\"end\", resolve);\n        });\n    });\n```\n\n### getAWSProfiles\n\nThis method asynchronously fetches a list of profile names in the credentials file:\n\n```javascript\nconst { getAWSProfiles } = require(\"aws-get-credentials\");\n\ngetAWSProfiles().then(profiles =\u003e {\n    // [\n    //     \"company-prod\",\n    //     \"company-stag\",\n    //     \"default\"\n    // ]\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Faws-get-credentials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperry-mitchell%2Faws-get-credentials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Faws-get-credentials/lists"}