1- import { Construct , Node } from 'constructs' ;
1+ import { Construct } from 'constructs' ;
22import {
33 CfnManagedPolicy ,
44 IGroupRef ,
@@ -13,9 +13,10 @@ import { AddToPrincipalPolicyResult, ArnPrincipal, IGrantable, IPrincipal, Princ
1313import { undefinedIfEmpty } from './private/util' ;
1414import { IRole } from './role' ;
1515import { IUser } from './user' ;
16- import { Arn , ArnFormat , Aws , Resource , ResourceEnvironment , Stack , UnscopedValidationError , ValidationError , Lazy } from '../../core' ;
16+ import { Arn , ArnFormat , Aws , Resource , Stack , ValidationError , Lazy } from '../../core' ;
1717import { getCustomizeRolesConfig , PolicySynthesizer } from '../../core/lib/helpers-internal' ;
1818import { addConstructMetadata , MethodMetadata } from '../../core/lib/metadata-resource' ;
19+ import { DetachedConstruct } from '../../core/lib/private/detached-construct' ;
1920import { propertyInjectable } from '../../core/lib/prop-injectable' ;
2021
2122/**
@@ -179,7 +180,7 @@ export class ManagedPolicy extends Resource implements IManagedPolicy, IGrantabl
179180 * prefix when constructing this object.
180181 */
181182 public static fromAwsManagedPolicyName ( managedPolicyName : string ) : IManagedPolicy {
182- class AwsManagedPolicy implements IManagedPolicy {
183+ class AwsManagedPolicy extends DetachedConstruct implements IManagedPolicy {
183184 public readonly managedPolicyArn = Arn . format ( {
184185 partition : Aws . PARTITION ,
185186 service : 'iam' ,
@@ -188,17 +189,14 @@ export class ManagedPolicy extends Resource implements IManagedPolicy, IGrantabl
188189 resource : 'policy' ,
189190 resourceName : managedPolicyName ,
190191 } ) ;
192+ constructor ( ) {
193+ super ( 'The result of fromAwsManagedPolicyName can not be used in this API' ) ;
194+ }
191195 public get managedPolicyRef ( ) : ManagedPolicyReference {
192196 return {
193197 policyArn : this . managedPolicyArn ,
194198 } ;
195199 }
196- public get node ( ) : Node {
197- throw new UnscopedValidationError ( 'The result of fromAwsManagedPolicyName can not be used in this API' ) ;
198- }
199- public get env ( ) : ResourceEnvironment {
200- throw new UnscopedValidationError ( 'The result of fromAwsManagedPolicyName can not be used in this API' ) ;
201- }
202200 }
203201 return new AwsManagedPolicy ( ) ;
204202 }
0 commit comments