Skip to content

Commit cf11a81

Browse files
authored
chore(appmesh): delegate grantStreamAggregatedResources to VirtualNodeGrants (#36141)
`VitualNode.grantStreamAggregatedResources()` isn't delegating its logic to `VirtualNodeGrants`. Fix that. Also update the README. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d24305c commit cf11a81

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

packages/aws-cdk-lib/aws-appmesh/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -913,18 +913,18 @@ appmesh.Mesh.fromMeshName(this, 'imported-mesh', 'abc');
913913

914914
## IAM Grants
915915

916-
`VirtualNode` and `VirtualGateway` provide `grantStreamAggregatedResources` methods that grant identities that are running
917-
Envoy access to stream generated config from App Mesh.
916+
`VirtualNode` and `VirtualGateway` have a `grants` property that provides a `streamAggregatedResources`
917+
methods that grant identities that are running Envoy access to stream generated config from App Mesh.
918918

919919
```ts
920920
declare const mesh: appmesh.Mesh;
921921
const gateway = new appmesh.VirtualGateway(this, 'testGateway', { mesh });
922922
const envoyUser = new iam.User(this, 'envoyUser');
923923

924924
/**
925-
* This will grant `grantStreamAggregatedResources` ONLY for this gateway.
925+
* This will grant `appmesh:StreamAggregatedResources` ONLY for this gateway.
926926
*/
927-
gateway.grantStreamAggregatedResources(envoyUser)
927+
gateway.grants.streamAggregatedResources(envoyUser)
928928
```
929929

930930
## Adding Resources to shared meshes

packages/aws-cdk-lib/aws-appmesh/lib/virtual-node.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Construct } from 'constructs';
2-
import { CfnVirtualNode } from './appmesh.generated';
2+
import { VirtualNodeGrants } from './appmesh-grants.generated';
3+
import { CfnVirtualNode, IVirtualNodeRef, VirtualNodeReference } from './appmesh.generated';
34
import { IMesh, Mesh } from './mesh';
45
import { renderMeshOwner, renderTlsClientPolicy } from './private/utils';
56
import { ServiceDiscovery, ServiceDiscoveryConfig } from './service-discovery';
@@ -13,7 +14,7 @@ import { propertyInjectable } from '../../core/lib/prop-injectable';
1314
/**
1415
* Interface which all VirtualNode based classes must implement
1516
*/
16-
export interface IVirtualNode extends cdk.IResource {
17+
export interface IVirtualNode extends cdk.IResource, IVirtualNodeRef {
1718
/**
1819
* The name of the VirtualNode
1920
*
@@ -116,12 +117,20 @@ abstract class VirtualNodeBase extends cdk.Resource implements IVirtualNode {
116117
*/
117118
public abstract readonly mesh: IMesh;
118119

120+
/**
121+
* Collection of grants for this Virtual Node
122+
*/
123+
public readonly grants = VirtualNodeGrants.fromVirtualNode(this);
124+
125+
public get virtualNodeRef(): VirtualNodeReference {
126+
return {
127+
virtualNodeArn: this.virtualNodeArn,
128+
virtualNodeId: this.virtualNodeName,
129+
};
130+
}
131+
119132
public grantStreamAggregatedResources(identity: iam.IGrantable): iam.Grant {
120-
return iam.Grant.addToPrincipal({
121-
grantee: identity,
122-
actions: ['appmesh:StreamAggregatedResources'],
123-
resourceArns: [this.virtualNodeArn],
124-
});
133+
return this.grants.streamAggregatedResources(identity);
125134
}
126135
}
127136

0 commit comments

Comments
 (0)