UNPKG

@fntio/infra-client

Version:

Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.

50 lines (49 loc) • 2.74 kB
import * as cdk from "aws-cdk-lib"; import { Construct } from "constructs"; import * as iam from "aws-cdk-lib/aws-iam"; /** One assumable target role for the quick path; the flexible path builds * any `iam.Role` with `webIdentityPrincipal()` as its `assumedBy` instead. */ export interface TargetRoleSpec { /** Must match the hub's Roles catalog; pinned into the trust policy's sub * condition — immutable once anything vends against it. */ readonly roleName: string; /** What the vended credentials may do — any IManagedPolicy works. */ readonly managedPolicies: readonly iam.IManagedPolicy[]; readonly description?: string; /** IAM cap on vended sessions (1h–12h; default 12h = STS max, so the * admin-set per-role session length in the app is the effective limit). */ readonly maxSessionDuration?: cdk.Duration; } /** Prepackaged common roles. Each roleName is a frozen contract baked into * deployed trust policies — entries may be added, never renamed. */ export declare const InfraClientRoles: { /** Account-wide read-only (AWS ReadOnlyAccess). */ READ_ONLY: { roleName: string; managedPolicies: cdk.aws_iam.IManagedPolicy[]; description: string; }; /** Full access except IAM/account management (AWS PowerUserAccess). */ POWER_USER: { roleName: string; managedPolicies: cdk.aws_iam.IManagedPolicy[]; description: string; }; /** Full administrative access (AWS AdministratorAccess). */ FULL_ADMIN: { roleName: string; managedPolicies: cdk.aws_iam.IManagedPolicy[]; description: string; }; }; /** The issuer URL as IAM condition keys name it: host only, no scheme or trailing slash. */ export declare const issuerHost: (issuerUrl: string) => string; /** The account's one OIDC provider for the hub's issuer. Reports the issuer * HOST as a literal — JSON policy condition keys cannot hold CFN tokens. */ export declare function createIssuerProvider(scope: Construct, id: string, issuerUrl: string): iam.IOpenIdConnectProvider; /** Pinned to audience + role-scoped sub — a token only assumes the role it * was minted for. The trusting role MUST use exactly this fixed roleName. */ export declare function webIdentityPrincipal(provider: iam.IOpenIdConnectProvider, roleName: string): iam.WebIdentityPrincipal; /** The same pin from a provider ARN and a literal issuer host — for a template whose provider is a native * `AWS::IAM::OIDCProvider` (no construct to ask) and whose account is only known at deploy time. */ export declare function webIdentityPrincipalFor(providerArn: string, issuer: string, roleName: string, account?: string): iam.WebIdentityPrincipal;