@aws/nx-plugin 0.60.2 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin",
3
- "version": "0.60.2",
3
+ "version": "0.61.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -813,13 +813,12 @@ import {
813
813
  Cors,
814
814
  LambdaIntegration,
815
815
  } from 'aws-cdk-lib/aws-apigateway';
816
- import { Duration, Stack } from 'aws-cdk-lib';
816
+ import { Duration } from 'aws-cdk-lib';
817
817
  import {
818
818
  PolicyDocument,
819
819
  PolicyStatement,
820
820
  Effect,
821
821
  AnyPrincipal,
822
- AccountPrincipal,
823
822
  IGrantable,
824
823
  Grant,
825
824
  } from 'aws-cdk-lib/aws-iam';
@@ -908,15 +907,6 @@ export class TestApi<
908
907
  },
909
908
  policy: new PolicyDocument({
910
909
  statements: [
911
- // Here we grant any AWS credentials from the account that the project is deployed in to call the api.
912
- // Machine to machine fine-grained access can be defined here using more specific principals (eg roles or
913
- // users) and resources (eg which api paths may be invoked by which principal) if required.
914
- new PolicyStatement({
915
- effect: Effect.ALLOW,
916
- principals: [new AccountPrincipal(Stack.of(scope).account)],
917
- actions: ['execute-api:Invoke'],
918
- resources: ['execute-api:/*'],
919
- }),
920
910
  // Open up OPTIONS to allow browsers to make unauthenticated preflight requests
921
911
  new PolicyStatement({
922
912
  effect: Effect.ALLOW,
@@ -937,6 +927,18 @@ export class TestApi<
937
927
  * @param grantee - The IAM principal to grant permissions to
938
928
  */
939
929
  public grantInvokeAccess(grantee: IGrantable) {
930
+ // Here we grant grantee permission to call the api.
931
+ // Machine to machine fine-grained access can be defined here using more specific principals (eg roles or
932
+ // users) and resources (eg which api paths may be invoked by which principal) if required.
933
+ this.api.addToResourcePolicy(
934
+ new PolicyStatement({
935
+ effect: Effect.ALLOW,
936
+ principals: [grantee.grantPrincipal],
937
+ actions: ['execute-api:Invoke'],
938
+ resources: ['execute-api:/*'],
939
+ }),
940
+ );
941
+
940
942
  Grant.addToPrincipal({
941
943
  grantee,
942
944
  actions: ['execute-api:Invoke'],