Socket
Book a DemoInstallSign in
Socket

aws-iam-policy-types

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-iam-policy-types

Autogenerated Typescript types for AWS IAM Policy and enums for all policy actions

1.0.2
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

AWS IAM Policy types

Autogenerated Typescript types for AWS IAM Policy and enums for policy actions for almost 400 AWS services.

This package provides typing and enums for AWS IAM Policies, as describes in

https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html.

Installation

npm i aws-iam-policy-types

Usage

import { IAM } from '@aws-sdk/client-iam';
import { AwsIAMPolicy, AwsStsActions } from 'aws-iam-policy-types';

// Configure the AWS SDK
const iam = new IAM({
  region: 'us-west-2',
  credentials: {
    accessKeyId: 'YOUR_ACCESS_KEY_ID',
    secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
  },
});

// Use `AwsIAMPolicy` to have type-safe policy
const assumeRolePolicyDocument: AwsIAMPolicy = {
  Version: policyVersion,
  Statement: [
    {
      Effect: 'Allow',
      Principal: {
        AWS: `arn:aws:iam::${awsAccountId}:root`,
      },
      // Use enums to have type-safe actions
      Action: AwsStsActions.AssumeRole,
    },
  ],
};
const { Role } = await iam.createRole({
  RoleName: 'MyRole',
  AssumeRolePolicyDocument: JSON.stringify(assumeRolePolicyDocument),
});

ExclusiveAwsIAMPolicy

There is also ExclusiveAwsIAMPolicy type, which is the same as AwsIAMPolicy, except the type is inferred to allow only one of Action/NotAction, and only one of Resource/NotResource.

Documentation

See here the full list of all available types

Contributing

Found a bug or hav a feature request? Please open a new issue.

When contributing with your code, please follow the standard best practices:

  • Make a fork with your changes, then make a Merge Request to merge it
  • Be polite

Keywords

aws

FAQs

Package last updated on 24 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.