"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Group=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),iam_generated_1=require("./iam.generated"),policy_1=require("./policy"),principals_1=require("./principals"),util_1=require("./util");class GroupBase extends core_1.Resource{constructor(){super(...arguments);this.grantPrincipal=this,this.principalAccount=this.env.account,this.assumeRoleAction="sts:AssumeRole",this.attachedPolicies=new util_1.AttachedPolicies}get policyFragment(){return new principals_1.ArnPrincipal(this.groupArn).policyFragment}attachInlinePolicy(policy){this.attachedPolicies.attach(policy),policy.attachToGroup(this)}addManagedPolicy(_policy){}addUser(user){user.addToGroup(this)}addToPrincipalPolicy(statement){return this.defaultPolicy||(this.defaultPolicy=new policy_1.Policy(this,"DefaultPolicy"),this.defaultPolicy.attachToGroup(this)),this.defaultPolicy.addStatements(statement),{statementAdded:!0,policyDependable:this.defaultPolicy}}addToPolicy(statement){return this.addToPrincipalPolicy(statement).statementAdded}}class Group extends GroupBase{constructor(scope,id,props={}){super(scope,id,{physicalName:props.groupName});this.managedPolicies=[],jsiiDeprecationWarnings.aws_cdk_lib_aws_iam_GroupProps(props),this.managedPolicies.push(...props.managedPolicies||[]);const group=new iam_generated_1.CfnGroup(this,"Resource",{groupName:this.physicalName,managedPolicyArns:core_1.Lazy.list({produce:()=>this.managedPolicies.map(p=>p.managedPolicyArn)},{omitEmpty:!0}),path:props.path});this.groupName=this.getResourceNameAttribute(group.ref),this.groupArn=this.getResourceArnAttribute(group.attrArn,{region:"",service:"iam",resource:"group",resourceName:this.physicalName})}static fromGroupArn(scope,id,groupArn){const arnComponents=core_1.Stack.of(scope).splitArn(groupArn,core_1.ArnFormat.SLASH_RESOURCE_NAME),groupName=arnComponents.resourceName;class Import extends GroupBase{constructor(){super(...arguments);this.groupName=groupName,this.groupArn=groupArn,this.principalAccount=arnComponents.account}}return new Import(scope,id)}static fromGroupName(scope,id,groupName){const groupArn=core_1.Stack.of(scope).formatArn({service:"iam",region:"",resource:"group",resourceName:groupName});return Group.fromGroupArn(scope,id,groupArn)}addManagedPolicy(policy){jsiiDeprecationWarnings.aws_cdk_lib_aws_iam_IManagedPolicy(policy),!this.managedPolicies.find(mp=>mp===policy)&&this.managedPolicies.push(policy)}}exports.Group=Group,_a=JSII_RTTI_SYMBOL_1,Group[_a]={fqn:"aws-cdk-lib.aws_iam.Group",version:"2.13.0"};
//# sourceMappingURL=group.js.map
