- Implements: IGithubActionsIdentityProvider
Github Actions as OpenID Connect Identity Provider for AWS IAM. There can be only one (per AWS Account).
Use fromAccount to retrieve a reference to existing Github OIDC provider.
Uses the native CloudFormation resource AWS::IAM::OIDCProvider (no Lambda functions).
import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc'
new GithubActionsIdentityProvider(scope: Construct, id: string, props?: GithubActionsIdentityProviderProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
CDK Stack or Construct to which the provider is assigned to. |
id |
string |
CDK Construct ID given to the construct. |
props |
GithubActionsIdentityProviderProps |
optional properties for the provider. |
- Type: constructs.Construct
CDK Stack or Construct to which the provider is assigned to.
- Type: string
CDK Construct ID given to the construct.
optional properties for the provider.
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
with |
Applies one or more mixins to this construct. |
applyCrossStackReferenceStrength |
Override the cross-stack reference strength for this resource. |
applyRemovalPolicy |
Apply the given removal policy to this resource. |
public toString(): stringReturns a string representation of this construct.
public with(mixins: ...IMixin[]): IConstructApplies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
- Type: ...constructs.IMixin[]
public applyCrossStackReferenceStrength(strength: ReferenceStrength): voidOverride the cross-stack reference strength for this resource.
When set, any cross-stack reference to this resource will use the specified
mechanism instead of the global default determined by the
@aws-cdk/core:defaultCrossStackReferences context key. This is useful for
selectively weakening specific references to avoid the "deadly embrace" problem
without changing the app-wide default.
- Type: aws-cdk-lib.ReferenceStrength
The reference strength to use for this resource.
public applyRemovalPolicy(policy: RemovalPolicy): voidApply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
- Type: aws-cdk-lib.RemovalPolicy
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
isOwnedResource |
Returns true if the construct was created by CDK, and false otherwise. |
isResource |
Check whether the given construct is a Resource. |
fromOidcProviderArn |
Imports an Open ID connect provider from an ARN. |
fromAccount |
Retrieve a reference to existing Github OIDC provider in your AWS account. |
import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc'
GithubActionsIdentityProvider.isConstruct(x: any)Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
- Type: any
Any object.
import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc'
GithubActionsIdentityProvider.isOwnedResource(construct: IConstruct)Returns true if the construct was created by CDK, and false otherwise.
- Type: constructs.IConstruct
import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc'
GithubActionsIdentityProvider.isResource(construct: IConstruct)Check whether the given construct is a Resource.
- Type: constructs.IConstruct
import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc'
GithubActionsIdentityProvider.fromOidcProviderArn(scope: Construct, id: string, oidcProviderArn: string)Imports an Open ID connect provider from an ARN.
- Type: constructs.Construct
The definition scope.
- Type: string
ID of the construct.
- Type: string
the ARN to import.
import { GithubActionsIdentityProvider } from 'aws-cdk-github-oidc'
GithubActionsIdentityProvider.fromAccount(scope: Construct, id: string)Retrieve a reference to existing Github OIDC provider in your AWS account.
An AWS account can only have single Github OIDC provider configured into it, so internally the reference is made by constructing the ARN from AWS Account ID & Github issuer URL.
Example
GithubActionsIdentityProvider.fromAccount(scope, "GithubProvider");- Type: constructs.Construct
CDK Stack or Construct to which the provider is assigned to.
- Type: string
CDK Construct ID given to the construct.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
env |
aws-cdk-lib.interfaces.ResourceEnvironment |
The environment this resource belongs to. |
stack |
aws-cdk-lib.Stack |
The stack in which this resource is defined. |
oidcProviderArn |
string |
The Amazon Resource Name (ARN) of the Native IAM OpenID Connect provider. |
oidcProviderIssuer |
string |
The issuer for the Native OIDC Provider. |
oidcProviderRef |
aws-cdk-lib.interfaces.aws_iam.OIDCProviderReference |
A reference to a OIDCProvider resource. |
oidcProviderThumbprints |
string |
The thumbprints configured for this provider. |
openIdConnectProviderArn |
string |
Alias for oidcProviderArn to maintain backwards compatibility for constructs which accept iam.IOpenIdConnectProvider. |
openIdConnectProviderIssuer |
string |
Alias for oidcProviderIssuer to maintain backwards compatibility for constructs which accept `iam.IOpenIdConnectProvider. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly env: ResourceEnvironment;- Type: aws-cdk-lib.interfaces.ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
public readonly stack: Stack;- Type: aws-cdk-lib.Stack
The stack in which this resource is defined.
public readonly oidcProviderArn: string;- Type: string
The Amazon Resource Name (ARN) of the Native IAM OpenID Connect provider.
public readonly oidcProviderIssuer: string;- Type: string
The issuer for the Native OIDC Provider.
public readonly oidcProviderRef: OIDCProviderReference;- Type: aws-cdk-lib.interfaces.aws_iam.OIDCProviderReference
A reference to a OIDCProvider resource.
public readonly oidcProviderThumbprints: string;- Type: string
The thumbprints configured for this provider.
public readonly openIdConnectProviderArn: string;- Type: string
Alias for oidcProviderArn to maintain backwards compatibility for constructs which accept iam.IOpenIdConnectProvider.
Use oidcProviderArn instead. This property exists for backward compatibility with existing constructs as migrating between the 2 constructs (OpenIdConnectProvider and OidcProviderNative) is not reasonably feasible as it requires a manual step (cdk import) since the resource type is changing between OpenIdConnectProvider and OidcProviderNative.
public readonly openIdConnectProviderIssuer: string;- Type: string
Alias for oidcProviderIssuer to maintain backwards compatibility for constructs which accept `iam.IOpenIdConnectProvider.
Use oidcProviderIssuer instead. This property exists for backward compatibility with existing constructs as migrating between the 2 constructs (OpenIdConnectProvider and OidcProviderNative) is not reasonably feasible as it requires a manual step (cdk import) since the resource type is changing between OpenIdConnectProvider and OidcProviderNative.
| Name | Type | Description |
|---|---|---|
PROPERTY_INJECTION_ID |
string |
Uniquely identifies this class. |
issuer |
string |
No description. |
public readonly PROPERTY_INJECTION_ID: string;- Type: string
Uniquely identifies this class.
public readonly issuer: string;- Type: string
Define an IAM Role that can be assumed by Github Actions workflow via Github OpenID Connect Identity Provider.
Besides GithubConfiguration, you may pass in any iam.RoleProps except assumedBy
which will be defined by this construct (CDK will fail if you do).
Example
const uploadRole = new GithubActionsRole(scope, "UploadRole", {
provider: GithubActionsIdentityProvider.fromAccount(scope, "GithubProvider"),
owner: 'octo-org',
repo: 'octo-repo',
filter: 'ref:refs/tags/v*',
roleName: 'MyUploadRole',
});
myBucket.grantWrite(uploadRole);import { GithubActionsRole } from 'aws-cdk-github-oidc'
new GithubActionsRole(scope: Construct, id: string, props: GithubActionsRoleProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
GithubActionsRoleProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: GithubActionsRoleProps
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
with |
Applies one or more mixins to this construct. |
applyCrossStackReferenceStrength |
Override the cross-stack reference strength for this resource. |
applyRemovalPolicy |
Skip applyRemovalPolicy if role synthesis is prevented by customizeRoles. |
addManagedPolicy |
Attaches a managed policy to this role. |
addToPolicy |
Add to the policy of this principal. |
addToPrincipalPolicy |
Adds a permission to the role's default policy document. |
attachInlinePolicy |
Attaches a policy to this role. |
grant |
Grant the actions defined in actions to the identity Principal on this resource. |
grantAssumeRole |
Grant permissions to the given principal to assume this role. |
grantPassRole |
Grant permissions to the given principal to pass this role. |
withoutPolicyUpdates |
Return a copy of this Role object whose Policies will not be updated. |
public toString(): stringReturns a string representation of this construct.
public with(mixins: ...IMixin[]): IConstructApplies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
- Type: ...constructs.IMixin[]
public applyCrossStackReferenceStrength(strength: ReferenceStrength): voidOverride the cross-stack reference strength for this resource.
When set, any cross-stack reference to this resource will use the specified
mechanism instead of the global default determined by the
@aws-cdk/core:defaultCrossStackReferences context key. This is useful for
selectively weakening specific references to avoid the "deadly embrace" problem
without changing the app-wide default.
- Type: aws-cdk-lib.ReferenceStrength
The reference strength to use for this resource.
public applyRemovalPolicy(policy: RemovalPolicy): voidSkip applyRemovalPolicy if role synthesis is prevented by customizeRoles.
Because in this case, this construct does not have a CfnResource in the tree.
- Type: aws-cdk-lib.RemovalPolicy
RemovalPolicy.
public addManagedPolicy(policy: IManagedPolicy): voidAttaches a managed policy to this role.
- Type: aws-cdk-lib.aws_iam.IManagedPolicy
The the managed policy to attach.
public addToPolicy(statement: PolicyStatement): booleanAdd to the policy of this principal.
- Type: aws-cdk-lib.aws_iam.PolicyStatement
public addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResultAdds a permission to the role's default policy document.
If there is no default policy attached to this role, it will be created.
- Type: aws-cdk-lib.aws_iam.PolicyStatement
The permission statement to add to the policy document.
public attachInlinePolicy(policy: Policy): voidAttaches a policy to this role.
- Type: aws-cdk-lib.aws_iam.Policy
The policy to attach.
public grant(grantee: IPrincipal, actions: ...string[]): GrantGrant the actions defined in actions to the identity Principal on this resource.
- Type: aws-cdk-lib.aws_iam.IPrincipal
- Type: ...string[]
public grantAssumeRole(identity: IPrincipal): GrantGrant permissions to the given principal to assume this role.
- Type: aws-cdk-lib.aws_iam.IPrincipal
public grantPassRole(identity: IPrincipal): GrantGrant permissions to the given principal to pass this role.
- Type: aws-cdk-lib.aws_iam.IPrincipal
public withoutPolicyUpdates(options?: WithoutPolicyUpdatesOptions): IRoleReturn a copy of this Role object whose Policies will not be updated.
Use the object returned by this method if you want this Role to be used by a construct without it automatically updating the Role's Policies.
If you do, you are responsible for adding the correct statements to the Role's policies yourself.
- Type: aws-cdk-lib.aws_iam.WithoutPolicyUpdatesOptions
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
isOwnedResource |
Returns true if the construct was created by CDK, and false otherwise. |
isResource |
Check whether the given construct is a Resource. |
customizeRoles |
Customize the creation of IAM roles within the given scope. |
fromLookup |
Lookup an existing Role. |
fromRoleArn |
Import an external role by ARN. |
fromRoleName |
Import an external role by name. |
isRole |
Return whether the given object is a Role. |
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.isConstruct(x: any)Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
- Type: any
Any object.
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.isOwnedResource(construct: IConstruct)Returns true if the construct was created by CDK, and false otherwise.
- Type: constructs.IConstruct
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.isResource(construct: IConstruct)Check whether the given construct is a Resource.
- Type: constructs.IConstruct
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.customizeRoles(scope: Construct, options?: CustomizeRolesOptions)Customize the creation of IAM roles within the given scope.
It is recommended that you do not use this method and instead allow CDK to manage role creation. This should only be used in environments where CDK applications are not allowed to created IAM roles.
This can be used to prevent the CDK application from creating roles
within the given scope and instead replace the references to the roles with
precreated role names. A report will be synthesized in the cloud assembly (i.e. cdk.out)
that will contain the list of IAM roles that would have been created along with the
IAM policy statements that the role should contain. This report can then be used
to create the IAM roles outside of CDK and then the created role names can be provided
in usePrecreatedRoles.
Example
declare const app: App;
iam.Role.customizeRoles(app, {
usePrecreatedRoles: {
'ConstructPath/To/Role': 'my-precreated-role-name',
},
});- Type: constructs.Construct
construct scope to customize role creation.
- Type: aws-cdk-lib.aws_iam.CustomizeRolesOptions
options for configuring role creation.
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.fromLookup(scope: Construct, id: string, options: RoleLookupOptions)Lookup an existing Role.
- Type: constructs.Construct
- Type: string
- Type: aws-cdk-lib.aws_iam.RoleLookupOptions
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.fromRoleArn(scope: Construct, id: string, roleArn: string, options?: FromRoleArnOptions)Import an external role by ARN.
If the imported Role ARN is a Token (such as a
CfnParameter.valueAsString or a Fn.importValue()) and the referenced
role has a path (like arn:...:role/AdminRoles/Alice), the
roleName property will not resolve to the correct value. Instead it
will resolve to the first path component. We unfortunately cannot express
the correct calculation of the full path name as a CloudFormation
expression. In this scenario the Role ARN should be supplied without the
path in order to resolve the correct role resource.
- Type: constructs.Construct
construct scope.
- Type: string
construct id.
- Type: string
the ARN of the role to import.
- Type: aws-cdk-lib.aws_iam.FromRoleArnOptions
allow customizing the behavior of the returned role.
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.fromRoleName(scope: Construct, id: string, roleName: string, options?: FromRoleNameOptions)Import an external role by name.
The imported role is assumed to exist in the same account as the account the scope's containing Stack is being deployed to.
- Type: constructs.Construct
construct scope.
- Type: string
construct id.
- Type: string
the name of the role to import.
- Type: aws-cdk-lib.aws_iam.FromRoleNameOptions
allow customizing the behavior of the returned role.
import { GithubActionsRole } from 'aws-cdk-github-oidc'
GithubActionsRole.isRole(x: any)Return whether the given object is a Role.
- Type: any
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
env |
aws-cdk-lib.interfaces.ResourceEnvironment |
The environment this resource belongs to. |
stack |
aws-cdk-lib.Stack |
The stack in which this resource is defined. |
assumeRoleAction |
string |
When this Principal is used in an AssumeRole policy, the action to use. |
grantPrincipal |
aws-cdk-lib.aws_iam.IPrincipal |
The principal to grant permissions to. |
grants |
aws-cdk-lib.aws_iam.RoleGrants |
Collection of grant methods for a Role. |
policyFragment |
aws-cdk-lib.aws_iam.PrincipalPolicyFragment |
Returns the role. |
roleArn |
string |
Returns the ARN of this role. |
roleId |
string |
Returns the stable and unique string identifying the role. |
roleName |
string |
Returns the name of the role. |
roleRef |
aws-cdk-lib.interfaces.aws_iam.RoleReference |
A reference to a Role resource. |
assumeRolePolicy |
aws-cdk-lib.aws_iam.PolicyDocument |
The assume role policy document associated with this role. |
permissionsBoundary |
aws-cdk-lib.aws_iam.IManagedPolicy |
Returns the permissions boundary attached to this role. |
principalAccount |
string |
The AWS account ID of this principal. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly env: ResourceEnvironment;- Type: aws-cdk-lib.interfaces.ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
public readonly stack: Stack;- Type: aws-cdk-lib.Stack
The stack in which this resource is defined.
public readonly assumeRoleAction: string;- Type: string
When this Principal is used in an AssumeRole policy, the action to use.
public readonly grantPrincipal: IPrincipal;- Type: aws-cdk-lib.aws_iam.IPrincipal
The principal to grant permissions to.
public readonly grants: RoleGrants;- Type: aws-cdk-lib.aws_iam.RoleGrants
Collection of grant methods for a Role.
public readonly policyFragment: PrincipalPolicyFragment;- Type: aws-cdk-lib.aws_iam.PrincipalPolicyFragment
Returns the role.
public readonly roleArn: string;- Type: string
Returns the ARN of this role.
public readonly roleId: string;- Type: string
Returns the stable and unique string identifying the role.
For example, AIDAJQABLZS4A3QDU576Q.
public readonly roleName: string;- Type: string
Returns the name of the role.
public readonly roleRef: RoleReference;- Type: aws-cdk-lib.interfaces.aws_iam.RoleReference
A reference to a Role resource.
public readonly assumeRolePolicy: PolicyDocument;- Type: aws-cdk-lib.aws_iam.PolicyDocument
The assume role policy document associated with this role.
public readonly permissionsBoundary: IManagedPolicy;- Type: aws-cdk-lib.aws_iam.IManagedPolicy
Returns the permissions boundary attached to this role.
public readonly principalAccount: string;- Type: string
The AWS account ID of this principal.
Can be undefined when the account is not known (for example, for service principals). Can be a Token - in that case, it's assumed to be AWS::AccountId.
| Name | Type | Description |
|---|---|---|
PROPERTY_INJECTION_ID |
string |
Uniquely identifies this class. |
public readonly PROPERTY_INJECTION_ID: string;- Type: string
Uniquely identifies this class.
import { GithubActionsIdentityProviderProps } from 'aws-cdk-github-oidc'
const githubActionsIdentityProviderProps: GithubActionsIdentityProviderProps = { ... }| Name | Type | Description |
|---|---|---|
removalPolicy |
aws-cdk-lib.RemovalPolicy |
The removal policy for the provider. |
public readonly removalPolicy: RemovalPolicy;- Type: aws-cdk-lib.RemovalPolicy
- Default: cdk.RemovalPolicy.DESTROY
The removal policy for the provider.
Props that define the IAM Role that can be assumed by Github Actions workflow via Github OpenID Connect Identity Provider.
Besides GithubConfiguration, you may pass in any iam.RoleProps except assumedBy
which will be defined by this construct (CDK will fail if you do).
Example
{
provider: GithubActionsIdentityProvider.fromAccount(scope, "GithubProvider"),
owner: 'octo-org',
repo: 'octo-repo',
filter: 'ref:refs/tags/v*',
roleName: 'MyDeployRole',
}import { GithubActionsRoleProps } from 'aws-cdk-github-oidc'
const githubActionsRoleProps: GithubActionsRoleProps = { ... }| Name | Type | Description |
|---|---|---|
owner |
string |
Repository owner (organization or username). |
provider |
IGithubActionsIdentityProvider |
Reference to Github OpenID Connect Provider configured in AWS IAM. |
repo |
string |
Repository name (slug) without the owner. |
filter |
string |
Subject condition filter, appended after repo:${owner}/${repo}: string in IAM Role trust relationship. |
ownerId |
string |
Numeric Github ID of the repository owner (organization or user), which makes the subject immutable. |
repoId |
string |
Numeric Github ID of the repository, which makes the subject immutable. |
description |
string |
A description of the role. |
externalIds |
string[] |
List of IDs that the role assumer needs to provide one of when assuming this role. |
inlinePolicies |
{[ key: string ]: aws-cdk-lib.aws_iam.PolicyDocument} |
A list of named policies to inline into this role. |
managedPolicies |
aws-cdk-lib.aws_iam.IManagedPolicy[] |
A list of managed policies associated with this role. |
maxSessionDuration |
aws-cdk-lib.Duration |
The maximum session duration that you want to set for the specified role. |
path |
string |
The path associated with this role. |
permissionsBoundary |
aws-cdk-lib.aws_iam.IManagedPolicy |
AWS supports permissions boundaries for IAM entities (users or roles). |
roleName |
string |
A name for the IAM role. |
public readonly owner: string;- Type: string
Repository owner (organization or username).
Example
'octo-org'public readonly provider: IGithubActionsIdentityProvider;Reference to Github OpenID Connect Provider configured in AWS IAM.
Either pass an construct defined by new GithubActionsIdentityProvider
or a retrieved reference from GithubActionsIdentityProvider.fromAccount.
There can be only one (per AWS Account).
public readonly repo: string;- Type: string
Repository name (slug) without the owner.
Example
'octo-repo'public readonly filter: string;- Type: string
- Default: '*' You may use this value to only allow Github to assume the role on specific branches, tags, environments, pull requests etc.
Subject condition filter, appended after repo:${owner}/${repo}: string in IAM Role trust relationship.
With ownerId & repoId given, appended after
repo:${owner}@${ownerId}/${repo}@${repoId}: instead.
Example
'ref:refs/tags/v*'
'ref:refs/heads/demo-branch'
'pull_request'
'environment:Production'public readonly ownerId: string;- Type: string
- Default: subject refers to the owner and repository by name
Numeric Github ID of the repository owner (organization or user), which makes the subject immutable.
Must be given together with repoId.
https://docs.github.com/en/actions/reference/security/oidc#immutable-subject-claims
Example
'123456'public readonly repoId: string;- Type: string
- Default: subject refers to the owner and repository by name
Numeric Github ID of the repository, which makes the subject immutable.
Must be given together with ownerId.
https://docs.github.com/en/actions/reference/security/oidc#immutable-subject-claims
Example
'456789'public readonly description: string;- Type: string
- Default: No description.
A description of the role.
It can be up to 1000 characters long.
public readonly externalIds: string[];- Type: string[]
- Default: No external ID required
List of IDs that the role assumer needs to provide one of when assuming this role.
If the configured and provided external IDs do not match, the AssumeRole operation will fail.
public readonly inlinePolicies: {[ key: string ]: PolicyDocument};- Type: {[ key: string ]: aws-cdk-lib.aws_iam.PolicyDocument}
- Default: No policy is inlined in the Role resource.
A list of named policies to inline into this role.
These policies will be
created with the role, whereas those added by addToPolicy are added
using a separate CloudFormation resource (allowing a way around circular
dependencies that could otherwise be introduced).
public readonly managedPolicies: IManagedPolicy[];- Type: aws-cdk-lib.aws_iam.IManagedPolicy[]
- Default: No managed policies.
A list of managed policies associated with this role.
You can add managed policies later using
addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName(policyName)).
public readonly maxSessionDuration: Duration;- Type: aws-cdk-lib.Duration
- Default: Duration.hours(1)
The maximum session duration that you want to set for the specified role.
This setting can have a value from 1 hour (3600sec) to 12 (43200sec) hours.
Anyone who assumes the role from the AWS CLI or API can use the DurationSeconds API parameter or the duration-seconds CLI parameter to request a longer session. The MaxSessionDuration setting determines the maximum duration that can be requested using the DurationSeconds parameter.
If users don't specify a value for the DurationSeconds parameter, their security credentials are valid for one hour by default. This applies when you use the AssumeRole* API operations or the assume-role* CLI operations but does not apply when you use those operations to create a console URL.
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html
public readonly path: string;- Type: string
- Default: /
The path associated with this role.
For information about IAM paths, see Friendly Names and Paths in IAM User Guide.
public readonly permissionsBoundary: IManagedPolicy;- Type: aws-cdk-lib.aws_iam.IManagedPolicy
- Default: No permissions boundary.
AWS supports permissions boundaries for IAM entities (users or roles).
A permissions boundary is an advanced feature for using a managed policy to set the maximum permissions that an identity-based policy can grant to an IAM entity. An entity's permissions boundary allows it to perform only the actions that are allowed by both its identity-based policies and its permissions boundaries.
https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html
public readonly roleName: string;- Type: string
- Default: AWS CloudFormation generates a unique physical ID and uses that ID for the role name.
A name for the IAM role.
For valid values, see the RoleName parameter for the CreateRole action in the IAM API Reference.
IMPORTANT: If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
If you specify a name, you must specify the CAPABILITY_NAMED_IAM value to acknowledge your template's capabilities. For more information, see Acknowledging IAM Resources in AWS CloudFormation Templates.
Github related configuration that forms the trust policy for this IAM Role.
import { GithubConfiguration } from 'aws-cdk-github-oidc'
const githubConfiguration: GithubConfiguration = { ... }| Name | Type | Description |
|---|---|---|
owner |
string |
Repository owner (organization or username). |
provider |
IGithubActionsIdentityProvider |
Reference to Github OpenID Connect Provider configured in AWS IAM. |
repo |
string |
Repository name (slug) without the owner. |
filter |
string |
Subject condition filter, appended after repo:${owner}/${repo}: string in IAM Role trust relationship. |
ownerId |
string |
Numeric Github ID of the repository owner (organization or user), which makes the subject immutable. |
repoId |
string |
Numeric Github ID of the repository, which makes the subject immutable. |
public readonly owner: string;- Type: string
Repository owner (organization or username).
Example
'octo-org'public readonly provider: IGithubActionsIdentityProvider;Reference to Github OpenID Connect Provider configured in AWS IAM.
Either pass an construct defined by new GithubActionsIdentityProvider
or a retrieved reference from GithubActionsIdentityProvider.fromAccount.
There can be only one (per AWS Account).
public readonly repo: string;- Type: string
Repository name (slug) without the owner.
Example
'octo-repo'public readonly filter: string;- Type: string
- Default: '*' You may use this value to only allow Github to assume the role on specific branches, tags, environments, pull requests etc.
Subject condition filter, appended after repo:${owner}/${repo}: string in IAM Role trust relationship.
With ownerId & repoId given, appended after
repo:${owner}@${ownerId}/${repo}@${repoId}: instead.
Example
'ref:refs/tags/v*'
'ref:refs/heads/demo-branch'
'pull_request'
'environment:Production'public readonly ownerId: string;- Type: string
- Default: subject refers to the owner and repository by name
Numeric Github ID of the repository owner (organization or user), which makes the subject immutable.
Must be given together with repoId.
https://docs.github.com/en/actions/reference/security/oidc#immutable-subject-claims
Example
'123456'public readonly repoId: string;- Type: string
- Default: subject refers to the owner and repository by name
Numeric Github ID of the repository, which makes the subject immutable.
Must be given together with ownerId.
https://docs.github.com/en/actions/reference/security/oidc#immutable-subject-claims
Example
'456789'Properties for defining an IAM Role.
These are copied fron
import { RoleProps } from 'aws-cdk-github-oidc'
const roleProps: RoleProps = { ... }| Name | Type | Description |
|---|---|---|
description |
string |
A description of the role. |
externalIds |
string[] |
List of IDs that the role assumer needs to provide one of when assuming this role. |
inlinePolicies |
{[ key: string ]: aws-cdk-lib.aws_iam.PolicyDocument} |
A list of named policies to inline into this role. |
managedPolicies |
aws-cdk-lib.aws_iam.IManagedPolicy[] |
A list of managed policies associated with this role. |
maxSessionDuration |
aws-cdk-lib.Duration |
The maximum session duration that you want to set for the specified role. |
path |
string |
The path associated with this role. |
permissionsBoundary |
aws-cdk-lib.aws_iam.IManagedPolicy |
AWS supports permissions boundaries for IAM entities (users or roles). |
roleName |
string |
A name for the IAM role. |
public readonly description: string;- Type: string
- Default: No description.
A description of the role.
It can be up to 1000 characters long.
public readonly externalIds: string[];- Type: string[]
- Default: No external ID required
List of IDs that the role assumer needs to provide one of when assuming this role.
If the configured and provided external IDs do not match, the AssumeRole operation will fail.
public readonly inlinePolicies: {[ key: string ]: PolicyDocument};- Type: {[ key: string ]: aws-cdk-lib.aws_iam.PolicyDocument}
- Default: No policy is inlined in the Role resource.
A list of named policies to inline into this role.
These policies will be
created with the role, whereas those added by addToPolicy are added
using a separate CloudFormation resource (allowing a way around circular
dependencies that could otherwise be introduced).
public readonly managedPolicies: IManagedPolicy[];- Type: aws-cdk-lib.aws_iam.IManagedPolicy[]
- Default: No managed policies.
A list of managed policies associated with this role.
You can add managed policies later using
addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName(policyName)).
public readonly maxSessionDuration: Duration;- Type: aws-cdk-lib.Duration
- Default: Duration.hours(1)
The maximum session duration that you want to set for the specified role.
This setting can have a value from 1 hour (3600sec) to 12 (43200sec) hours.
Anyone who assumes the role from the AWS CLI or API can use the DurationSeconds API parameter or the duration-seconds CLI parameter to request a longer session. The MaxSessionDuration setting determines the maximum duration that can be requested using the DurationSeconds parameter.
If users don't specify a value for the DurationSeconds parameter, their security credentials are valid for one hour by default. This applies when you use the AssumeRole* API operations or the assume-role* CLI operations but does not apply when you use those operations to create a console URL.
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html
public readonly path: string;- Type: string
- Default: /
The path associated with this role.
For information about IAM paths, see Friendly Names and Paths in IAM User Guide.
public readonly permissionsBoundary: IManagedPolicy;- Type: aws-cdk-lib.aws_iam.IManagedPolicy
- Default: No permissions boundary.
AWS supports permissions boundaries for IAM entities (users or roles).
A permissions boundary is an advanced feature for using a managed policy to set the maximum permissions that an identity-based policy can grant to an IAM entity. An entity's permissions boundary allows it to perform only the actions that are allowed by both its identity-based policies and its permissions boundaries.
https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html
public readonly roleName: string;- Type: string
- Default: AWS CloudFormation generates a unique physical ID and uses that ID for the role name.
A name for the IAM role.
For valid values, see the RoleName parameter for the CreateRole action in the IAM API Reference.
IMPORTANT: If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
If you specify a name, you must specify the CAPABILITY_NAMED_IAM value to acknowledge your template's capabilities. For more information, see Acknowledging IAM Resources in AWS CloudFormation Templates.
-
Extends: aws-cdk-lib.aws_iam.IOidcProvider
-
Implemented By: GithubActionsIdentityProvider, IGithubActionsIdentityProvider
Describes a Github OpenID Connect Identity Provider for AWS IAM.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
env |
aws-cdk-lib.interfaces.ResourceEnvironment |
The environment this resource belongs to. |
stack |
aws-cdk-lib.Stack |
The stack in which this resource is defined. |
oidcProviderRef |
aws-cdk-lib.interfaces.aws_iam.OIDCProviderReference |
A reference to a OIDCProvider resource. |
oidcProviderArn |
string |
The Amazon Resource Name (ARN) of the IAM OpenID Connect provider. |
oidcProviderIssuer |
string |
The issuer for OIDC Provider. |
openIdConnectProviderArn |
string |
Alias for oidcProviderArn to maintain backwards compatibility for constructs which accept iam.IOpenIdConnectProvider. |
openIdConnectProviderIssuer |
string |
Alias for oidcProviderIssuer to maintain backwards compatibility for constructs which accept `iam.IOpenIdConnectProvider. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly env: ResourceEnvironment;- Type: aws-cdk-lib.interfaces.ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
public readonly stack: Stack;- Type: aws-cdk-lib.Stack
The stack in which this resource is defined.
public readonly oidcProviderRef: OIDCProviderReference;- Type: aws-cdk-lib.interfaces.aws_iam.OIDCProviderReference
A reference to a OIDCProvider resource.
public readonly oidcProviderArn: string;- Type: string
The Amazon Resource Name (ARN) of the IAM OpenID Connect provider.
public readonly oidcProviderIssuer: string;- Type: string
The issuer for OIDC Provider.
public readonly openIdConnectProviderArn: string;- Type: string
Alias for oidcProviderArn to maintain backwards compatibility for constructs which accept iam.IOpenIdConnectProvider.
Use oidcProviderArn instead. This property exists for backward compatibility with existing constructs as migrating between the 2 constructs (OpenIdConnectProvider and OidcProviderNative) is not reasonably feasible as it requires a manual step (cdk import) since the resource type is changing between OpenIdConnectProvider and OidcProviderNative.
public readonly openIdConnectProviderIssuer: string;- Type: string
Alias for oidcProviderIssuer to maintain backwards compatibility for constructs which accept `iam.IOpenIdConnectProvider.
Use oidcProviderIssuer instead. This property exists for backward compatibility with existing constructs as migrating between the 2 constructs (OpenIdConnectProvider and OidcProviderNative) is not reasonably feasible as it requires a manual step (cdk import) since the resource type is changing between OpenIdConnectProvider and OidcProviderNative.