aws-iam-managed-policies 0.0.6 → 0.0.8

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/README.md CHANGED
@@ -4,14 +4,538 @@ Automatically populated (every morning at 6AM UTC) repository of AWS IAM Managed
4
4
  ## Data
5
5
  The raw IAM Managed Policies data can be found in the [data/json](https://github.com/tobilg/aws-iam-managed-policies/tree/main/data/json) directory. It is categorized by Managed Policy name and version id.
6
6
 
7
- ## Usage
8
-
9
- ### Installation
7
+ ## Installation
10
8
  You can install the npm package like this:
11
9
 
12
10
  ```bash
13
11
  npm i --save aws-iam-managed-policies
14
12
  ```
15
13
 
16
- ### API
14
+ ## API Docs
17
15
  The API docs can be found at [https://tobilg.github.io/aws-iam-managed-policies](https://tobilg.github.io/aws-iam-managed-policies).
16
+
17
+ ## Usage examples
18
+ ```javascript
19
+ const {
20
+ getPolicyCount,
21
+ listPolicies,
22
+ getPolicyByName,
23
+ getLatestPolicyDocument,
24
+ getPolicyDocumentByVersion,
25
+ getPolicyDiffByVersions
26
+ } = require('aws-iam-managed-policies');
27
+ ```
28
+
29
+ ### Get the number of Managed Policies
30
+ ```javascript
31
+ console.log(getPolicyCount());
32
+ /*
33
+ 1117
34
+ */
35
+ ```
36
+
37
+ ### Get the first 10 policy names
38
+ ```javascript
39
+ console.log(listPolicies().filter((p, i) => i <= 9));
40
+ /*
41
+ [
42
+ "APIGatewayServiceRolePolicy",
43
+ "AWSAccountActivityAccess",
44
+ "AWSAccountManagementFullAccess",
45
+ "AWSAccountManagementReadOnlyAccess",
46
+ "AWSAccountUsageReportAccess",
47
+ "AWSAgentlessDiscoveryService",
48
+ "AWSAppFabricFullAccess",
49
+ "AWSAppFabricReadOnlyAccess",
50
+ "AWSAppFabricServiceRolePolicy",
51
+ "AWSAppMeshEnvoyAccess"
52
+ ]
53
+ */
54
+ ```
55
+
56
+ ### Get policy by name 'AdministratorAccess'
57
+ ```javascript
58
+ console.log(getPolicyByName('AdministratorAccess'));
59
+ /*
60
+ {
61
+ "arn": "arn:aws:iam::aws:policy/AdministratorAccess",
62
+ "latestVersionId": "v1",
63
+ "versionsCount": 1,
64
+ "versions": {
65
+ "v1": {
66
+ "createdDate": "2015-02-06T18:39:46.000Z",
67
+ "document": {
68
+ "Version": "2012-10-17",
69
+ "Statement": [
70
+ {
71
+ "Effect": "Allow",
72
+ "Action": "*",
73
+ "Resource": "*"
74
+ }
75
+ ]
76
+ }
77
+ }
78
+ },
79
+ "createdDate": "2015-02-06T18:39:46.000Z",
80
+ "lastUpdatedDate": "2015-02-06T18:39:46.000Z"
81
+ }
82
+ */
83
+ ```
84
+
85
+ ### Get latest policy document for policy 'AdministratorAccess'
86
+ ```javascript
87
+ console.log(getLatestPolicyDocument('AdministratorAccess'));
88
+ /*
89
+ {
90
+ "Version": "2012-10-17",
91
+ "Statement": [
92
+ {
93
+ "Effect": "Allow",
94
+ "Action": "*",
95
+ "Resource": "*"
96
+ }
97
+ ]
98
+ }
99
+ */
100
+ ```
101
+
102
+ ### Get version '5' policy document for policy 'ViewOnlyAccess'
103
+ ```javascript
104
+ console.log(getPolicyDocumentByVersion('ViewOnlyAccess', 5));
105
+ /*
106
+ {
107
+ "Version": "2012-10-17",
108
+ "Statement": [
109
+ {
110
+ "Action": [
111
+ "acm:ListCertificates",
112
+ "athena:List*",
113
+ "aws-marketplace:ViewSubscriptions",
114
+ "autoscaling:Describe*",
115
+ "batch:ListJobs",
116
+ "clouddirectory:ListAppliedSchemaArns",
117
+ "clouddirectory:ListDevelopmentSchemaArns",
118
+ "clouddirectory:ListDirectories",
119
+ "clouddirectory:ListPublishedSchemaArns",
120
+ "cloudformation:List*",
121
+ "cloudformation:DescribeStacks",
122
+ "cloudfront:List*",
123
+ "cloudhsm:ListAvailableZones",
124
+ "cloudhsm:ListLunaClients",
125
+ "cloudhsm:ListHapgs",
126
+ "cloudhsm:ListHsms",
127
+ "cloudsearch:List*",
128
+ "cloudsearch:DescribeDomains",
129
+ "cloudtrail:DescribeTrails",
130
+ "cloudtrail:LookupEvents",
131
+ "cloudwatch:List*",
132
+ "cloudwatch:GetMetricData",
133
+ "codebuild:ListBuilds*",
134
+ "codebuild:ListProjects",
135
+ "codecommit:List*",
136
+ "codedeploy:List*",
137
+ "codedeploy:Get*",
138
+ "codepipeline:ListPipelines",
139
+ "codestar:List*",
140
+ "codestar:Verify*",
141
+ "cognito-idp:List*",
142
+ "cognito-identity:ListIdentities",
143
+ "cognito-identity:ListIdentityPools",
144
+ "cognito-sync:ListDatasets",
145
+ "connect:List*",
146
+ "config:List*",
147
+ "config:Describe*",
148
+ "datapipeline:ListPipelines",
149
+ "datapipeline:DescribePipelines",
150
+ "datapipeline:GetAccountLimits",
151
+ "devicefarm:List*",
152
+ "directconnect:Describe*",
153
+ "discovery:List*",
154
+ "dms:List*",
155
+ "ds:DescribeDirectories",
156
+ "dynamodb:ListTables",
157
+ "ec2:DescribeAccountAttributes",
158
+ "ec2:DescribeAddresses",
159
+ "ec2:DescribeAvailabilityZones",
160
+ "ec2:DescribeBundleTasks",
161
+ "ec2:DescribeClassicLinkInstances",
162
+ "ec2:DescribeConversionTasks",
163
+ "ec2:DescribeCustomerGateways",
164
+ "ec2:DescribeDhcpOptions",
165
+ "ec2:DescribeExportTasks",
166
+ "ec2:DescribeFlowLogs",
167
+ "ec2:DescribeHost*",
168
+ "ec2:DescribeIdentityIdFormat",
169
+ "ec2:DescribeIdFormat",
170
+ "ec2:DescribeImage*",
171
+ "ec2:DescribeImport*",
172
+ "ec2:DescribeInstance*",
173
+ "ec2:DescribeInternetGateways",
174
+ "ec2:DescribeKeyPairs",
175
+ "ec2:DescribeMovingAddresses",
176
+ "ec2:DescribeNatGateways",
177
+ "ec2:DescribeNetwork*",
178
+ "ec2:DescribePlacementGroups",
179
+ "ec2:DescribePrefixLists",
180
+ "ec2:DescribeRegions",
181
+ "ec2:DescribeReserved*",
182
+ "ec2:DescribeRouteTables",
183
+ "ec2:DescribeSecurityGroups",
184
+ "ec2:DescribeSnapshot*",
185
+ "ec2:DescribeSpot*",
186
+ "ec2:DescribeSubnets",
187
+ "ec2:DescribeVolume*",
188
+ "ec2:DescribeVpc*",
189
+ "ec2:DescribeVpnGateways",
190
+ "ecr:DescribeRepositories",
191
+ "ecr:ListImages",
192
+ "ecs:List*",
193
+ "ecs:Describe*",
194
+ "elasticache:Describe*",
195
+ "elasticbeanstalk:DescribeApplicationVersions",
196
+ "elasticbeanstalk:DescribeApplications",
197
+ "elasticbeanstalk:DescribeEnvironments",
198
+ "elasticbeanstalk:ListAvailableSolutionStacks",
199
+ "elasticloadbalancing:DescribeListeners",
200
+ "elasticloadbalancing:DescribeLoadBalancers",
201
+ "elasticloadbalancing:DescribeTargetGroups",
202
+ "elasticloadbalancing:DescribeTargetHealth",
203
+ "elasticfilesystem:DescribeFileSystems",
204
+ "elasticmapreduce:List*",
205
+ "elastictranscoder:List*",
206
+ "es:DescribeElasticsearchDomain",
207
+ "es:DescribeElasticsearchDomains",
208
+ "es:ListDomainNames",
209
+ "events:ListRuleNamesByTarget",
210
+ "events:ListRules",
211
+ "events:ListTargetsByRule",
212
+ "firehose:List*",
213
+ "firehose:DescribeDeliveryStream",
214
+ "gamelift:List*",
215
+ "glacier:List*",
216
+ "iam:List*",
217
+ "iam:GetAccountSummary",
218
+ "iam:GetLoginProfile",
219
+ "importexport:ListJobs",
220
+ "inspector:List*",
221
+ "iot:List*",
222
+ "kinesis:ListStreams",
223
+ "kinesisanalytics:ListApplications",
224
+ "kms:ListKeys",
225
+ "lambda:List*",
226
+ "lex:GetBotAliases",
227
+ "lex:GetBotChannelAssociations",
228
+ "lex:GetBots",
229
+ "lex:GetBotVersions",
230
+ "lex:GetIntents",
231
+ "lex:GetIntentVersions",
232
+ "lex:GetSlotTypes",
233
+ "lex:GetSlotTypeVersions",
234
+ "lex:GetUtterancesView",
235
+ "lightsail:GetBlueprints",
236
+ "lightsail:GetBundles",
237
+ "lightsail:GetInstances",
238
+ "lightsail:GetInstanceSnapshots",
239
+ "lightsail:GetKeyPair",
240
+ "lightsail:GetRegions",
241
+ "lightsail:GetStaticIps",
242
+ "lightsail:IsVpcPeered",
243
+ "logs:Describe*",
244
+ "machinelearning:Describe*",
245
+ "mobilehub:ListAvailableFeatures",
246
+ "mobilehub:ListAvailableRegions",
247
+ "mobilehub:ListProjects",
248
+ "opsworks:Describe*",
249
+ "opsworks-cm:Describe*",
250
+ "organizations:List*",
251
+ "mobiletargeting:GetApplicationSettings",
252
+ "mobiletargeting:GetCampaigns",
253
+ "mobiletargeting:GetImportJobs",
254
+ "mobiletargeting:GetSegments",
255
+ "polly:Describe*",
256
+ "polly:List*",
257
+ "rds:Describe*",
258
+ "redshift:DescribeClusters",
259
+ "redshift:DescribeEvents",
260
+ "redshift:ViewQueriesInConsole",
261
+ "route53:List*",
262
+ "route53:Get*",
263
+ "route53domains:List*",
264
+ "s3:ListAllMyBuckets",
265
+ "s3:ListBucket",
266
+ "sagemaker:Describe*",
267
+ "sagemaker:List*",
268
+ "sdb:List*",
269
+ "servicecatalog:List*",
270
+ "ses:List*",
271
+ "shield:List*",
272
+ "states:ListActivities",
273
+ "states:ListStateMachines",
274
+ "sns:List*",
275
+ "sqs:ListQueues",
276
+ "ssm:ListAssociations",
277
+ "ssm:ListDocuments",
278
+ "storagegateway:ListGateways",
279
+ "storagegateway:ListLocalDisks",
280
+ "storagegateway:ListVolumeRecoveryPoints",
281
+ "storagegateway:ListVolumes",
282
+ "swf:List*",
283
+ "trustedadvisor:Describe*",
284
+ "waf:List*",
285
+ "waf-regional:List*",
286
+ "workdocs:DescribeAvailableDirectories",
287
+ "workdocs:DescribeInstances",
288
+ "workmail:Describe*",
289
+ "workspaces:Describe*"
290
+ ],
291
+ "Effect": "Allow",
292
+ "Resource": "*"
293
+ }
294
+ ]
295
+ }
296
+ */
297
+ ```
298
+
299
+ ### Get a version comparison of versions '5' and '17' policy document for policy 'ViewOnlyAccess'
300
+ ```javascript
301
+ console.log(getPolicyDiffByVersions('ViewOnlyAccess', 5, 17));
302
+ /*
303
+ {
304
+ "added": {
305
+ "Statement": {
306
+ "0": {
307
+ "Action": {
308
+ "179": "mediaconnect:ListReservations",
309
+ "180": "mobiletargeting:GetApplicationSettings",
310
+ "181": "mobiletargeting:GetCampaigns",
311
+ "182": "mobiletargeting:GetImportJobs",
312
+ "183": "mobiletargeting:GetSegments",
313
+ "184": "opsworks-cm:Describe*",
314
+ "185": "opsworks:Describe*",
315
+ "186": "organizations:List*",
316
+ "187": "outposts:GetOutpost",
317
+ "188": "outposts:GetOutpostInstanceTypes",
318
+ "189": "outposts:ListOutposts",
319
+ "190": "outposts:ListSites",
320
+ "191": "outposts:ListTagsForResource",
321
+ "192": "polly:Describe*",
322
+ "193": "polly:List*",
323
+ "194": "rds:Describe*",
324
+ "195": "redshift:DescribeClusters",
325
+ "196": "redshift:DescribeEvents",
326
+ "197": "redshift:ViewQueriesInConsole",
327
+ "198": "resource-explorer-2:GetDefaultView",
328
+ "199": "resource-explorer-2:GetIndex",
329
+ "200": "resource-explorer-2:ListIndexes",
330
+ "201": "resource-explorer-2:ListSupportedResourceTypes",
331
+ "202": "resource-explorer-2:ListTagsForResource",
332
+ "203": "resource-explorer-2:ListViews",
333
+ "204": "route53:Get*",
334
+ "205": "route53:List*",
335
+ "206": "route53domains:List*",
336
+ "207": "route53resolver:Get*",
337
+ "208": "route53resolver:List*",
338
+ "209": "s3:ListAllMyBuckets",
339
+ "210": "s3:ListBucket",
340
+ "211": "sagemaker:Describe*",
341
+ "212": "sagemaker:List*",
342
+ "213": "sdb:List*",
343
+ "214": "servicecatalog:List*",
344
+ "215": "ses:List*",
345
+ "216": "shield:List*",
346
+ "217": "sns:List*",
347
+ "218": "sqs:ListQueues",
348
+ "219": "ssm:ListAssociations",
349
+ "220": "ssm:ListDocuments",
350
+ "221": "states:ListActivities",
351
+ "222": "states:ListStateMachines",
352
+ "223": "storagegateway:ListGateways",
353
+ "224": "storagegateway:ListLocalDisks",
354
+ "225": "storagegateway:ListVolumeRecoveryPoints",
355
+ "226": "storagegateway:ListVolumes",
356
+ "227": "swf:List*",
357
+ "228": "trustedadvisor:Describe*",
358
+ "229": "waf-regional:List*",
359
+ "230": "waf:List*",
360
+ "231": "wafv2:List*",
361
+ "232": "workdocs:DescribeAvailableDirectories",
362
+ "233": "workdocs:DescribeInstances",
363
+ "234": "workmail:Describe*",
364
+ "235": "workspaces:Describe*"
365
+ }
366
+ }
367
+ }
368
+ },
369
+ "deleted": {},
370
+ "updated": {
371
+ "Statement": {
372
+ "0": {
373
+ "Action": {
374
+ "2": "autoscaling:Describe*",
375
+ "3": "aws-marketplace:ViewSubscriptions",
376
+ "9": "cloudformation:DescribeStacks",
377
+ "10": "cloudformation:List*",
378
+ "13": "cloudhsm:ListHapgs",
379
+ "14": "cloudhsm:ListHsms",
380
+ "15": "cloudhsm:ListLunaClients",
381
+ "16": "cloudsearch:DescribeDomains",
382
+ "17": "cloudsearch:List*",
383
+ "20": "cloudwatch:Get*",
384
+ "21": "cloudwatch:List*",
385
+ "25": "codedeploy:Get*",
386
+ "26": "codedeploy:List*",
387
+ "29": "cognito-identity:ListIdentities",
388
+ "30": "cognito-identity:ListIdentityPools",
389
+ "31": "cognito-idp:List*",
390
+ "32": "cognito-sync:ListDatasets",
391
+ "33": "config:Describe*",
392
+ "34": "config:List*",
393
+ "35": "connect:List*",
394
+ "36": "comprehend:Describe*",
395
+ "37": "comprehend:List*",
396
+ "40": "datapipeline:ListPipelines",
397
+ "41": "dax:DescribeClusters",
398
+ "42": "dax:DescribeDefaultParameters",
399
+ "43": "dax:DescribeEvents",
400
+ "44": "dax:DescribeParameterGroups",
401
+ "45": "dax:DescribeParameters",
402
+ "46": "dax:DescribeSubnetGroups",
403
+ "47": "dax:ListTags",
404
+ "48": "devicefarm:List*",
405
+ "49": "directconnect:Describe*",
406
+ "50": "discovery:List*",
407
+ "51": "dms:List*",
408
+ "52": "ds:DescribeDirectories",
409
+ "53": "dynamodb:DescribeBackup",
410
+ "54": "dynamodb:DescribeContinuousBackups",
411
+ "55": "dynamodb:DescribeGlobalTable",
412
+ "56": "dynamodb:DescribeGlobalTableSettings",
413
+ "57": "dynamodb:DescribeLimits",
414
+ "58": "dynamodb:DescribeReservedCapacity",
415
+ "59": "dynamodb:DescribeReservedCapacityOfferings",
416
+ "60": "dynamodb:DescribeStream",
417
+ "61": "dynamodb:DescribeTable",
418
+ "62": "dynamodb:DescribeTimeToLive",
419
+ "63": "dynamodb:ListBackups",
420
+ "64": "dynamodb:ListGlobalTables",
421
+ "65": "dynamodb:ListStreams",
422
+ "66": "dynamodb:ListTables",
423
+ "67": "dynamodb:ListTagsOfResource",
424
+ "68": "ec2:DescribeAccountAttributes",
425
+ "69": "ec2:DescribeAddresses",
426
+ "70": "ec2:DescribeAvailabilityZones",
427
+ "71": "ec2:DescribeBundleTasks",
428
+ "72": "ec2:DescribeCarrierGateways",
429
+ "73": "ec2:DescribeClassicLinkInstances",
430
+ "74": "ec2:DescribeConversionTasks",
431
+ "75": "ec2:DescribeCustomerGateways",
432
+ "76": "ec2:DescribeDhcpOptions",
433
+ "77": "ec2:DescribeExportTasks",
434
+ "78": "ec2:DescribeFlowLogs",
435
+ "79": "ec2:DescribeHost*",
436
+ "80": "ec2:DescribeIdFormat",
437
+ "81": "ec2:DescribeIdentityIdFormat",
438
+ "82": "ec2:DescribeImage*",
439
+ "83": "ec2:DescribeImport*",
440
+ "84": "ec2:DescribeInstance*",
441
+ "85": "ec2:DescribeInternetGateways",
442
+ "86": "ec2:DescribeKeyPairs",
443
+ "87": "ec2:DescribeLocalGatewayRouteTableVirtualInterfaceGroupAssociations",
444
+ "88": "ec2:DescribeLocalGatewayRouteTableVpcAssociations",
445
+ "89": "ec2:DescribeLocalGatewayRouteTables",
446
+ "90": "ec2:DescribeLocalGatewayVirtualInterfaceGroups",
447
+ "91": "ec2:DescribeLocalGatewayVirtualInterfaces",
448
+ "92": "ec2:DescribeLocalGateways",
449
+ "93": "ec2:DescribeMovingAddresses",
450
+ "94": "ec2:DescribeNatGateways",
451
+ "95": "ec2:DescribeNetwork*",
452
+ "96": "ec2:DescribePlacementGroups",
453
+ "97": "ec2:DescribePrefixLists",
454
+ "98": "ec2:DescribeRegions",
455
+ "99": "ec2:DescribeReserved*",
456
+ "100": "ec2:DescribeRouteTables",
457
+ "101": "ec2:DescribeSecurityGroupRules",
458
+ "102": "ec2:DescribeSecurityGroups",
459
+ "103": "ec2:DescribeSnapshot*",
460
+ "104": "ec2:DescribeSpot*",
461
+ "105": "ec2:DescribeSubnets",
462
+ "106": "ec2:DescribeTags",
463
+ "107": "ec2:DescribeVolume*",
464
+ "108": "ec2:DescribeVpc*",
465
+ "109": "ec2:DescribeVpnGateways",
466
+ "110": "ec2:SearchLocalGatewayRoutes",
467
+ "111": "ecr:DescribeRepositories",
468
+ "112": "ecr:ListImages",
469
+ "113": "ecs:Describe*",
470
+ "114": "ecs:List*",
471
+ "115": "elastic-inference:DescribeAccelerators",
472
+ "116": "elastic-inference:DescribeAcceleratorTypes",
473
+ "117": "elastic-inference:DescribeAcceleratorOfferings",
474
+ "118": "elastic-inference:ListTagsForResource",
475
+ "119": "elasticache:Describe*",
476
+ "120": "elasticbeanstalk:DescribeApplicationVersions",
477
+ "121": "elasticbeanstalk:DescribeApplications",
478
+ "122": "elasticbeanstalk:DescribeEnvironments",
479
+ "123": "elasticbeanstalk:ListAvailableSolutionStacks",
480
+ "124": "elasticfilesystem:DescribeFileSystems",
481
+ "125": "elasticloadbalancing:DescribeInstanceHealth",
482
+ "126": "elasticloadbalancing:DescribeListeners",
483
+ "127": "elasticloadbalancing:DescribeLoadBalancers",
484
+ "128": "elasticloadbalancing:DescribeTargetGroups",
485
+ "129": "elasticloadbalancing:DescribeTargetHealth",
486
+ "130": "elasticmapreduce:List*",
487
+ "131": "elastictranscoder:List*",
488
+ "132": "es:DescribeElasticsearchDomain",
489
+ "133": "es:DescribeElasticsearchDomains",
490
+ "134": "es:ListDomainNames",
491
+ "135": "events:ListRuleNamesByTarget",
492
+ "136": "events:ListRules",
493
+ "137": "events:ListTargetsByRule",
494
+ "138": "firehose:DescribeDeliveryStream",
495
+ "139": "firehose:List*",
496
+ "140": "fsx:DescribeFileSystems",
497
+ "141": "gamelift:List*",
498
+ "142": "glacier:List*",
499
+ "143": "greengrass:List*",
500
+ "144": "iam:GetAccountSummary",
501
+ "145": "iam:GetLoginProfile",
502
+ "146": "iam:List*",
503
+ "147": "importexport:ListJobs",
504
+ "148": "inspector:List*",
505
+ "149": "iot:List*",
506
+ "150": "kinesis:ListStreams",
507
+ "151": "kinesisanalytics:ListApplications",
508
+ "152": "kms:ListKeys",
509
+ "153": "lambda:List*",
510
+ "154": "lex:GetBotAliases",
511
+ "155": "lex:GetBotChannelAssociations",
512
+ "156": "lex:GetBotVersions",
513
+ "157": "lex:GetBots",
514
+ "158": "lex:GetIntentVersions",
515
+ "159": "lex:GetIntents",
516
+ "160": "lex:GetSlotTypeVersions",
517
+ "161": "lex:GetSlotTypes",
518
+ "162": "lex:GetUtterancesView",
519
+ "163": "lightsail:GetBlueprints",
520
+ "164": "lightsail:GetBundles",
521
+ "165": "lightsail:GetInstanceSnapshots",
522
+ "166": "lightsail:GetInstances",
523
+ "167": "lightsail:GetKeyPair",
524
+ "168": "lightsail:GetRegions",
525
+ "169": "lightsail:GetStaticIps",
526
+ "170": "lightsail:IsVpcPeered",
527
+ "171": "logs:Describe*",
528
+ "172": "lookoutvision:ListModelPackagingJobs",
529
+ "173": "lookoutvision:ListModels",
530
+ "174": "lookoutvision:ListProjects",
531
+ "175": "machinelearning:Describe*",
532
+ "176": "mediaconnect:ListEntitlements",
533
+ "177": "mediaconnect:ListFlows",
534
+ "178": "mediaconnect:ListOfferings"
535
+ }
536
+ }
537
+ }
538
+ }
539
+ }
540
+ */
541
+ ```
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare const listPolicies: () => string[];
10
10
  */
11
11
  export declare const getPolicyCount: () => number;
12
12
  /**
13
- * Get the IAM Managed Policy by name
13
+ * Get the IAM Managed Policy by name with the full version history
14
14
  * @param {string} policyName The IAM Managed Policy name.
15
15
  * @returns {object} The IAM Managed Policy if found.
16
16
  * @throws Will throw an error if not found by the name.
@@ -31,4 +31,13 @@ export declare const getLatestPolicyDocument: (policyName: string) => object;
31
31
  * @throws Will throw an error if not found by the name.
32
32
  */
33
33
  export declare const getPolicyDocumentByVersion: (policyName: string, policyVersion: number) => object;
34
+ /**
35
+ * Get a diff of the policy documents for two versions of a IAM Managed Policy
36
+ * @param {string} policyName The IAM Managed Policy name.
37
+ * @param {number} oldPolicyVersion The old version id of the IAM Managed Policy.
38
+ * @param {number} newPolicyVersion The new version id of the IAM Managed Policy.
39
+ * @returns {object} The diff of the IAM Managed Policy document versions if found.
40
+ * @throws Will throw an error if not found by the name or the respective policy document versions.
41
+ */
42
+ export declare const getPolicyDiffByVersions: (policyName: string, oldPolicyVersion: number, newPolicyVersion: number) => object;
34
43
  export { ManagedPolicies, };
package/dist/index.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPolicyDocumentByVersion = exports.getLatestPolicyDocument = exports.getPolicyByName = exports.getPolicyCount = exports.listPolicies = void 0;
6
+ exports.getPolicyDiffByVersions = exports.getPolicyDocumentByVersion = exports.getLatestPolicyDocument = exports.getPolicyByName = exports.getPolicyCount = exports.listPolicies = void 0;
7
+ var deep_object_diff_1 = require("deep-object-diff");
7
8
  var managedPolicies_json_1 = __importDefault(require("./managedPolicies.json"));
8
9
  var sortObjectByPropertyNames = function (obj) { return Object.keys(obj).sort().reduce(function (objEntries, key) {
9
10
  objEntries[key] = obj[key];
@@ -26,7 +27,7 @@ var getPolicyCount = function () {
26
27
  };
27
28
  exports.getPolicyCount = getPolicyCount;
28
29
  /**
29
- * Get the IAM Managed Policy by name
30
+ * Get the IAM Managed Policy by name with the full version history
30
31
  * @param {string} policyName The IAM Managed Policy name.
31
32
  * @returns {object} The IAM Managed Policy if found.
32
33
  * @throws Will throw an error if not found by the name.
@@ -67,11 +68,35 @@ exports.getLatestPolicyDocument = getLatestPolicyDocument;
67
68
  */
68
69
  var getPolicyDocumentByVersion = function (policyName, policyVersion) {
69
70
  var policy = managedPolicies_json_1.default[policyName];
70
- if (policy && policy.versions[policyVersion]) {
71
- return policy.versions[policyVersion].document;
71
+ if (policy && policy.versions["v".concat(policyVersion)]) {
72
+ return policy.versions["v".concat(policyVersion)].document;
72
73
  }
73
74
  else {
74
75
  throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(policyVersion, "'!"));
75
76
  }
76
77
  };
77
78
  exports.getPolicyDocumentByVersion = getPolicyDocumentByVersion;
79
+ /**
80
+ * Get a diff of the policy documents for two versions of a IAM Managed Policy
81
+ * @param {string} policyName The IAM Managed Policy name.
82
+ * @param {number} oldPolicyVersion The old version id of the IAM Managed Policy.
83
+ * @param {number} newPolicyVersion The new version id of the IAM Managed Policy.
84
+ * @returns {object} The diff of the IAM Managed Policy document versions if found.
85
+ * @throws Will throw an error if not found by the name or the respective policy document versions.
86
+ */
87
+ var getPolicyDiffByVersions = function (policyName, oldPolicyVersion, newPolicyVersion) {
88
+ var policy = managedPolicies_json_1.default[policyName];
89
+ if (policy) {
90
+ if (!policy.versions["v".concat(oldPolicyVersion)]) {
91
+ throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(oldPolicyVersion, "'!"));
92
+ }
93
+ if (!policy.versions["v".concat(newPolicyVersion)]) {
94
+ throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(newPolicyVersion, "'!"));
95
+ }
96
+ return (0, deep_object_diff_1.detailedDiff)(policy.versions["v".concat(oldPolicyVersion)].document, policy.versions["v".concat(newPolicyVersion)].document);
97
+ }
98
+ else {
99
+ throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found!"));
100
+ }
101
+ };
102
+ exports.getPolicyDiffByVersions = getPolicyDiffByVersions;
@@ -132803,8 +132803,8 @@
132803
132803
  },
132804
132804
  "AmazonRedshiftServiceLinkedRolePolicy": {
132805
132805
  "arn": "arn:aws:iam::aws:policy/aws-service-role/AmazonRedshiftServiceLinkedRolePolicy",
132806
- "latestVersionId": "v10",
132807
- "versionsCount": 10,
132806
+ "latestVersionId": "v11",
132807
+ "versionsCount": 11,
132808
132808
  "versions": {
132809
132809
  "v1": {
132810
132810
  "createdDate": "2017-09-18T19:19:45.000Z",
@@ -134017,10 +134017,210 @@
134017
134017
  }
134018
134018
  ]
134019
134019
  }
134020
+ },
134021
+ "v11": {
134022
+ "createdDate": "2017-09-18T19:19:45.000Z",
134023
+ "document": {
134024
+ "Version": "2012-10-17",
134025
+ "Statement": [
134026
+ {
134027
+ "Effect": "Allow",
134028
+ "Action": [
134029
+ "ec2:DescribeVpcs",
134030
+ "ec2:DescribeSubnets",
134031
+ "ec2:DescribeNetworkInterfaces",
134032
+ "ec2:DescribeAddresses",
134033
+ "ec2:AssociateAddress",
134034
+ "ec2:DisassociateAddress",
134035
+ "ec2:CreateNetworkInterface",
134036
+ "ec2:DeleteNetworkInterface",
134037
+ "ec2:ModifyNetworkInterfaceAttribute",
134038
+ "ec2:CreateVpcEndpoint",
134039
+ "ec2:DeleteVpcEndpoints",
134040
+ "ec2:DescribeVpcEndpoints",
134041
+ "ec2:ModifyVpcEndpoint"
134042
+ ],
134043
+ "Resource": "*"
134044
+ },
134045
+ {
134046
+ "Effect": "Allow",
134047
+ "Action": [
134048
+ "ec2:AllocateAddress"
134049
+ ],
134050
+ "Resource": [
134051
+ "arn:aws:ec2:*:*:elastic-ip/*"
134052
+ ],
134053
+ "Condition": {
134054
+ "StringEquals": {
134055
+ "aws:RequestTag/Redshift": "true"
134056
+ }
134057
+ }
134058
+ },
134059
+ {
134060
+ "Effect": "Allow",
134061
+ "Action": [
134062
+ "ec2:ReleaseAddress"
134063
+ ],
134064
+ "Resource": [
134065
+ "arn:aws:ec2:*:*:elastic-ip/*"
134066
+ ],
134067
+ "Condition": {
134068
+ "StringEquals": {
134069
+ "aws:ResourceTag/Redshift": "true"
134070
+ }
134071
+ }
134072
+ },
134073
+ {
134074
+ "Sid": "EnableCreationAndManagementOfRedshiftCloudwatchLogGroups",
134075
+ "Effect": "Allow",
134076
+ "Action": [
134077
+ "logs:CreateLogGroup",
134078
+ "logs:PutRetentionPolicy"
134079
+ ],
134080
+ "Resource": [
134081
+ "arn:aws:logs:*:*:log-group:/aws/redshift/*"
134082
+ ]
134083
+ },
134084
+ {
134085
+ "Sid": "EnableCreationAndManagementOfRedshiftCloudwatchLogStreams",
134086
+ "Effect": "Allow",
134087
+ "Action": [
134088
+ "logs:CreateLogStream",
134089
+ "logs:PutLogEvents",
134090
+ "logs:DescribeLogStreams",
134091
+ "logs:GetLogEvents"
134092
+ ],
134093
+ "Resource": [
134094
+ "arn:aws:logs:*:*:log-group:/aws/redshift/*:log-stream:*"
134095
+ ]
134096
+ },
134097
+ {
134098
+ "Effect": "Allow",
134099
+ "Action": [
134100
+ "ec2:CreateSecurityGroup"
134101
+ ],
134102
+ "Resource": [
134103
+ "arn:aws:ec2:*:*:security-group/*"
134104
+ ],
134105
+ "Condition": {
134106
+ "StringEquals": {
134107
+ "aws:RequestTag/Redshift": "true"
134108
+ }
134109
+ }
134110
+ },
134111
+ {
134112
+ "Effect": "Allow",
134113
+ "Action": [
134114
+ "ec2:AuthorizeSecurityGroupEgress",
134115
+ "ec2:AuthorizeSecurityGroupIngress",
134116
+ "ec2:RevokeSecurityGroupEgress",
134117
+ "ec2:RevokeSecurityGroupIngress",
134118
+ "ec2:ModifySecurityGroupRules",
134119
+ "ec2:DeleteSecurityGroup"
134120
+ ],
134121
+ "Resource": [
134122
+ "arn:aws:ec2:*:*:security-group/*"
134123
+ ],
134124
+ "Condition": {
134125
+ "StringEquals": {
134126
+ "aws:ResourceTag/Redshift": "true"
134127
+ }
134128
+ }
134129
+ },
134130
+ {
134131
+ "Effect": "Allow",
134132
+ "Action": [
134133
+ "ec2:CreateSecurityGroup"
134134
+ ],
134135
+ "Resource": [
134136
+ "arn:aws:ec2:*:*:vpc/*"
134137
+ ]
134138
+ },
134139
+ {
134140
+ "Effect": "Allow",
134141
+ "Action": "ec2:CreateTags",
134142
+ "Resource": [
134143
+ "arn:aws:ec2:*:*:subnet/*",
134144
+ "arn:aws:ec2:*:*:route-table/*",
134145
+ "arn:aws:ec2:*:*:security-group/*",
134146
+ "arn:aws:ec2:*:*:vpc/*",
134147
+ "arn:aws:ec2:*:*:internet-gateway/*",
134148
+ "arn:aws:ec2:*:*:elastic-ip/*"
134149
+ ],
134150
+ "Condition": {
134151
+ "StringEquals": {
134152
+ "ec2:CreateAction": [
134153
+ "CreateVpc",
134154
+ "CreateSecurityGroup",
134155
+ "CreateSubnet",
134156
+ "CreateInternetGateway",
134157
+ "CreateRouteTable",
134158
+ "AllocateAddress"
134159
+ ]
134160
+ }
134161
+ }
134162
+ },
134163
+ {
134164
+ "Effect": "Allow",
134165
+ "Action": [
134166
+ "ec2:DescribeVpcAttribute",
134167
+ "ec2:DescribeSecurityGroups",
134168
+ "ec2:DescribeInternetGateways",
134169
+ "ec2:DescribeSecurityGroupRules",
134170
+ "ec2:DescribeAvailabilityZones",
134171
+ "ec2:DescribeNetworkAcls",
134172
+ "ec2:DescribeRouteTables"
134173
+ ],
134174
+ "Resource": "*"
134175
+ },
134176
+ {
134177
+ "Effect": "Allow",
134178
+ "Action": [
134179
+ "cloudwatch:PutMetricData"
134180
+ ],
134181
+ "Resource": "*",
134182
+ "Condition": {
134183
+ "StringEquals": {
134184
+ "cloudwatch:namespace": [
134185
+ "AWS/Redshift-Serverless",
134186
+ "AWS/Redshift"
134187
+ ]
134188
+ }
134189
+ }
134190
+ },
134191
+ {
134192
+ "Effect": "Allow",
134193
+ "Action": [
134194
+ "secretsmanager:DescribeSecret",
134195
+ "secretsmanager:DeleteSecret",
134196
+ "secretsmanager:PutSecretValue",
134197
+ "secretsmanager:UpdateSecret",
134198
+ "secretsmanager:UpdateSecretVersionStage",
134199
+ "secretsmanager:RotateSecret"
134200
+ ],
134201
+ "Resource": [
134202
+ "arn:aws:secretsmanager:*:*:secret:redshift!*"
134203
+ ],
134204
+ "Condition": {
134205
+ "StringEquals": {
134206
+ "secretsmanager:ResourceTag/aws:secretsmanager:owningService": "redshift",
134207
+ "aws:ResourceAccount": "${aws:PrincipalAccount}"
134208
+ }
134209
+ }
134210
+ },
134211
+ {
134212
+ "Effect": "Allow",
134213
+ "Action": [
134214
+ "secretsmanager:GetRandomPassword"
134215
+ ],
134216
+ "Resource": "*"
134217
+ }
134218
+ ]
134219
+ }
134020
134220
  }
134021
134221
  },
134022
134222
  "createdDate": "2017-09-18T19:19:45.000Z",
134023
- "lastUpdatedDate": "2023-05-08T18:57:44.000Z"
134223
+ "lastUpdatedDate": "2023-08-14T10:46:23.000Z"
134024
134224
  },
134025
134225
  "AWSElasticLoadBalancingServiceRolePolicy": {
134026
134226
  "arn": "arn:aws:iam::aws:policy/aws-service-role/AWSElasticLoadBalancingServiceRolePolicy",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-iam-managed-policies",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Provides AWS IAM Managed Policies historical data as a convenient npm package that can be used in other OSS projects.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -41,5 +41,8 @@
41
41
  "p-limit": "3.1.0",
42
42
  "ts-node": "^10.9.1",
43
43
  "typescript": "^5.1.6"
44
+ },
45
+ "dependencies": {
46
+ "deep-object-diff": "^1.1.9"
44
47
  }
45
48
  }