npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cdk-multi-profile-plugin

v2.1.0

Published

Adds multi profile/account, mfa and aws sso support to cdk apps

Downloads

6,101

Readme

cdk-multi-profile-plugin

Build Status

Adds multi profile/account, mfa and aws sso support to cdk apps

Installation

npm install cdk-multi-profile-plugin aws-sdk

How to use

Plugin configuration

There are two ways to tell cdk to use the plugin. The first way is to include an explicit --plugin option whenever you use a cdk command.

npx cdk deploy --plugin "cdk-multi-profile-plugin" *Stack

The second way is to add the following entry to the cdk.json file

// cdk.json
{
  "app": "npx ts-node bin/YOURAPP.ts",
  "plugin": ["cdk-multi-profile-plugin"]
}

Configure account mapping

Add the account / profile mapping in the package.json

// package.json
{
    ...
    "devDependencies": {
        "aws-cdk": "^1.15.0",
        "cdk-multi-profile-plugin": "^0.0.1",
        ...
    }
    "awsProfiles": {
        "YOUR_ACCOUNT_ID": "YOUR_PROFILE",
        "YOUR_ACCOUNT_ID": "YOUR_PROFILE",
    }
}

Finally add the account number to the environment of your stack.

new CdkStack(app, `Stack`, {
  env: {
    account: "1234number",
  },
});

Precedence of account number to profile mapping

When working in a team every team member should be allowed to have an individual configuration of locally configured AWS profiles. There also might be a need to override the mapping for an account within a build job.

The following order defines the precedence of your mapping:

  1. Global configuration file ~/.cdkmultiprofileplugin.json (can be overridden using the CDK_MULTI_PROFILE_PLUGIN_CONFIG environment variable)
  2. Project local configuration file <projectDir>/cdkmultiprofileplugin.json
  3. Project local package.json

The <projectDir>/cdkmultiprofileplugin.json can optionally be under version control. This depends on your preference.

package.json approach works if you can ensure equal AWS profile names across all team members or build runners.

package.json based mapping is overrideable by using <projectDir>/cdkmultiprofileplugin.json. The configuration file <projectDir>/cdkmultiprofileplugin.json can be ignored or put under version control. This decision is dependant on your use case. Either you also ensure equal AWS profile names for every team member and build runner. In this case, it safely can be put under version control. You can locally override your mapping if you choose to ignore it.

With the global configuration file you can override all of the approaches above. The location of the global configuration file is ~/.cdkmultiprofileplugin.json. To customize the location of the configuration file use the environment variable CDK_MULTI_PROFILE_PLUGIN_CONFIG.

The configuration uses the following json based format. The plugin will ignore unknown or additionals fields in the configuration.

`{
    "awsProfiles": {
        "123": "default123",
        "456": "default123"
    }
}`

AWS SSO

Before you can run an aws cdk with aws sso, you must retrieve and cache a set of temporary credentials. To get these temporary credentials, run the following command.

aws sso login --profile sso-profile

Environment Variables

The plugin supports the following environment variables:

  • AWS_SHARED_CREDENTIALS_FILE – Specifies the location of the file that the AWS CLI uses to store access keys. The default path is ~/.aws/credentials).
  • AWS_CONFIG_FILE - The location of the config file used by this plugin. By default this value is ~/.aws/config.
  • IGNORE_CDK_MULTI_PROFILE_PLUGIN=true - Turn off the plugin. Defaults to false.
  • CDK_MULTI_PROFILE_PLUGIN_CONFIG - Specifies the localtion of the global account to profile mapping. Defaults to ~/.cdkmultiprofileplugin.json

License

MIT