nate2-scripts 1.0.3__tar.gz → 2.0.1__tar.gz

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.
Files changed (130) hide show
  1. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/.gitignore +2 -1
  2. nate2_scripts-2.0.1/PKG-INFO +221 -0
  3. nate2_scripts-2.0.1/README.md +206 -0
  4. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/pyproject.toml +15 -1
  5. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/src/nate2_scripts/bing_wrapper/__init__.py +4 -2
  6. nate2_scripts-2.0.1/src/nate2_scripts/console/__init__.py +207 -0
  7. nate2_scripts-2.0.1/src/nate2_scripts/console/boto3_session.py +51 -0
  8. nate2_scripts-1.0.3/src/nate2_scripts/console/hashGrabber.py → nate2_scripts-2.0.1/src/nate2_scripts/console/hash_grabber.py +27 -12
  9. nate2_scripts-2.0.1/src/nate2_scripts/console/local_refresh.py +0 -0
  10. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/__init__.py +44 -0
  11. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/apigateway.py +11 -0
  12. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/artifact.py +11 -0
  13. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/athena.py +11 -0
  14. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/batch.py +52 -0
  15. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/bedrock.py +11 -0
  16. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/cloudformation.py +28 -0
  17. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/cloudfront.py +12 -0
  18. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/cloudhsm.py +11 -0
  19. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/cloudtrail.py +11 -0
  20. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/cognito.py +11 -0
  21. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/config.py +11 -0
  22. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/controltower.py +11 -0
  23. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/cost.py +13 -0
  24. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/datasync.py +11 -0
  25. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/dynamo.py +27 -0
  26. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/ec2.py +118 -0
  27. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/ecr.py +16 -0
  28. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/ecs.py +61 -0
  29. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/efs.py +11 -0
  30. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/eks.py +11 -0
  31. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/elasticbeanstalk.py +11 -0
  32. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/elb.py +35 -0
  33. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/eventbridge.py +11 -0
  34. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/fsx.py +11 -0
  35. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/glue.py +11 -0
  36. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/guardduty.py +11 -0
  37. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/iam.py +43 -0
  38. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/inspector.py +11 -0
  39. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/kms.py +11 -0
  40. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/lambda_.py +45 -0
  41. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/lex.py +11 -0
  42. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/lightsail.py +11 -0
  43. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/logs.py +81 -0
  44. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/marketplace.py +24 -0
  45. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/polly.py +11 -0
  46. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/quick.py +15 -0
  47. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/rds.py +34 -0
  48. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/route53.py +16 -0
  49. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/s3.py +66 -0
  50. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/sagemaker.py +11 -0
  51. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/scheduler.py +11 -0
  52. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/secretsmanager.py +31 -0
  53. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/sns.py +29 -0
  54. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/sqs.py +28 -0
  55. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/ssm.py +18 -0
  56. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/stepfunctions.py +37 -0
  57. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/storagegateway.py +11 -0
  58. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/support.py +14 -0
  59. nate2_scripts-2.0.1/src/nate2_scripts/console/resolvers/vpc.py +93 -0
  60. nate2_scripts-1.0.3/src/nate2_scripts/console/sessionCache.py → nate2_scripts-2.0.1/src/nate2_scripts/console/session_cache.py +8 -26
  61. nate2_scripts-2.0.1/src/nate2_scripts/console/text_resolver.py +197 -0
  62. nate2_scripts-2.0.1/src/nate2_scripts/console/types.py +59 -0
  63. nate2_scripts-2.0.1/tests/__init__.py +0 -0
  64. nate2_scripts-2.0.1/tests/console/__init__.py +0 -0
  65. nate2_scripts-2.0.1/tests/console/resolvers/__init__.py +43 -0
  66. nate2_scripts-2.0.1/tests/console/resolvers/apigateway.py +34 -0
  67. nate2_scripts-2.0.1/tests/console/resolvers/artifact.py +21 -0
  68. nate2_scripts-2.0.1/tests/console/resolvers/athena.py +34 -0
  69. nate2_scripts-2.0.1/tests/console/resolvers/batch.py +50 -0
  70. nate2_scripts-2.0.1/tests/console/resolvers/bedrock.py +36 -0
  71. nate2_scripts-2.0.1/tests/console/resolvers/cloudformation.py +132 -0
  72. nate2_scripts-2.0.1/tests/console/resolvers/cloudfront.py +34 -0
  73. nate2_scripts-2.0.1/tests/console/resolvers/cloudhsm.py +34 -0
  74. nate2_scripts-2.0.1/tests/console/resolvers/cloudtrail.py +34 -0
  75. nate2_scripts-2.0.1/tests/console/resolvers/cognito.py +34 -0
  76. nate2_scripts-2.0.1/tests/console/resolvers/config.py +34 -0
  77. nate2_scripts-2.0.1/tests/console/resolvers/conftest.py +40 -0
  78. nate2_scripts-2.0.1/tests/console/resolvers/controltower.py +21 -0
  79. nate2_scripts-2.0.1/tests/console/resolvers/cost.py +22 -0
  80. nate2_scripts-2.0.1/tests/console/resolvers/datasync.py +34 -0
  81. nate2_scripts-2.0.1/tests/console/resolvers/dynamo.py +47 -0
  82. nate2_scripts-2.0.1/tests/console/resolvers/ec2.py +269 -0
  83. nate2_scripts-2.0.1/tests/console/resolvers/ecr.py +34 -0
  84. nate2_scripts-2.0.1/tests/console/resolvers/ecs.py +60 -0
  85. nate2_scripts-2.0.1/tests/console/resolvers/efs.py +21 -0
  86. nate2_scripts-2.0.1/tests/console/resolvers/eks.py +21 -0
  87. nate2_scripts-2.0.1/tests/console/resolvers/elasticbeanstalk.py +34 -0
  88. nate2_scripts-2.0.1/tests/console/resolvers/elb.py +34 -0
  89. nate2_scripts-2.0.1/tests/console/resolvers/eventbridge.py +34 -0
  90. nate2_scripts-2.0.1/tests/console/resolvers/fsx.py +21 -0
  91. nate2_scripts-2.0.1/tests/console/resolvers/glue.py +21 -0
  92. nate2_scripts-2.0.1/tests/console/resolvers/guardduty.py +34 -0
  93. nate2_scripts-2.0.1/tests/console/resolvers/iam.py +21 -0
  94. nate2_scripts-2.0.1/tests/console/resolvers/inspector.py +21 -0
  95. nate2_scripts-2.0.1/tests/console/resolvers/kms.py +21 -0
  96. nate2_scripts-2.0.1/tests/console/resolvers/lambda_.py +202 -0
  97. nate2_scripts-2.0.1/tests/console/resolvers/lex.py +21 -0
  98. nate2_scripts-2.0.1/tests/console/resolvers/lightsail.py +34 -0
  99. nate2_scripts-2.0.1/tests/console/resolvers/logs.py +258 -0
  100. nate2_scripts-2.0.1/tests/console/resolvers/marketplace.py +60 -0
  101. nate2_scripts-2.0.1/tests/console/resolvers/polly.py +21 -0
  102. nate2_scripts-2.0.1/tests/console/resolvers/rds.py +21 -0
  103. nate2_scripts-2.0.1/tests/console/resolvers/route53.py +34 -0
  104. nate2_scripts-2.0.1/tests/console/resolvers/s3.py +305 -0
  105. nate2_scripts-2.0.1/tests/console/resolvers/sagemaker.py +34 -0
  106. nate2_scripts-2.0.1/tests/console/resolvers/scheduler.py +34 -0
  107. nate2_scripts-2.0.1/tests/console/resolvers/secretsmanager.py +47 -0
  108. nate2_scripts-2.0.1/tests/console/resolvers/sns.py +21 -0
  109. nate2_scripts-2.0.1/tests/console/resolvers/sqs.py +21 -0
  110. nate2_scripts-2.0.1/tests/console/resolvers/ssm.py +89 -0
  111. nate2_scripts-2.0.1/tests/console/resolvers/stepfunctions.py +21 -0
  112. nate2_scripts-2.0.1/tests/console/resolvers/storagegateway.py +34 -0
  113. nate2_scripts-2.0.1/tests/console/resolvers/support.py +36 -0
  114. nate2_scripts-2.0.1/tests/console/resolvers/vpc.py +58 -0
  115. nate2_scripts-2.0.1/tests/console/test_aws/config +35 -0
  116. nate2_scripts-2.0.1/tests/console/test_aws/credentials +11 -0
  117. nate2_scripts-1.0.3/CONSOLE-NOTES.md +0 -70
  118. nate2_scripts-1.0.3/PKG-INFO +0 -9
  119. nate2_scripts-1.0.3/README.md +0 -93
  120. nate2_scripts-1.0.3/src/nate2_scripts/console/__init__.py +0 -211
  121. nate2_scripts-1.0.3/src/nate2_scripts/console/arnResolver.py +0 -514
  122. nate2_scripts-1.0.3/src/nate2_scripts/console/destitationResolver.py +0 -116
  123. nate2_scripts-1.0.3/src/nate2_scripts/console/nameResolver.py +0 -106
  124. nate2_scripts-1.0.3/src/nate2_scripts/console/regionCache.py +0 -50
  125. nate2_scripts-1.0.3/src/nate2_scripts/console/resourceIdResolver.py +0 -176
  126. nate2_scripts-1.0.3/src/nate2_scripts/test.py +0 -98
  127. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/.github/workflows/publish.yml +0 -0
  128. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/LICENSE +0 -0
  129. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/src/nate2_scripts/__init__.py +0 -0
  130. {nate2_scripts-1.0.3 → nate2_scripts-2.0.1}/src/nate2_scripts/bing_wrapper/autocomplete.sh +0 -0
@@ -1,3 +1,4 @@
1
1
  __pycache__
2
2
  dist
3
- .vscode
3
+ .vscode
4
+ uv.lock
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.5
2
+ Name: nate2-scripts
3
+ Version: 2.0.1
4
+ Summary: Utility scripts for AWS development on macOS
5
+ Project-URL: Homepage, https://github.com/tennex-nwestfall/nate2-scripts
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: argcomplete
9
+ Requires-Dist: boto3
10
+ Provides-Extra: dev
11
+ Requires-Dist: boto3-stubs[essential]; extra == 'dev'
12
+ Requires-Dist: moto[all]; extra == 'dev'
13
+ Requires-Dist: pytest; extra == 'dev'
14
+ Description-Content-Type: text/markdown
15
+
16
+ [![PyPI version](https://img.shields.io/pypi/v/nate2-scripts)](https://pypi.org/project/nate2-scripts/)
17
+ [![License](https://img.shields.io/github/license/tennex-nwestfall/nate2-scripts)](https://github.com/tennex-nwestfall/nate2-scripts/blob/main/LICENSE)
18
+
19
+ # Nate2's Scripts
20
+
21
+ Utility scripts for AWS development on macOS.
22
+
23
+ To install run:
24
+
25
+ ```bash
26
+ pip install nate2-scripts
27
+ ```
28
+
29
+ To update run:
30
+
31
+ ```bash
32
+ pip install --upgrade nate2-scripts
33
+ ```
34
+
35
+ ## Scripts
36
+
37
+ ### `console`
38
+
39
+ Opens the AWS Management Console in your browser for a specific service, ARN, resource id, or resource name, using federated sign-in from your current AWS credentials. Supports multi-session via searching browser history sqlite databases.
40
+
41
+ **Requirements:**
42
+
43
+ - `AWS_PROFILE` set (e.g. via `asp`)
44
+ - `git config user.email` set — it is used as the `role_session_name` for every assume-role profile
45
+
46
+ **Example Alias:**
47
+
48
+ ```bash
49
+ # noglob is so that one can paste in logs arns that end with :*
50
+ # otherwise zsh tries to see the log arn as a glob and fails
51
+ alias co="noglob console"
52
+ # needed for autocomplete
53
+ eval "$(register-python-argcomplete console)"
54
+ ```
55
+
56
+ **Usage:**
57
+
58
+ ```bash
59
+ console [service | arn | id | name] [search ...] [-r REGION] [-f]
60
+ ```
61
+
62
+ ```bash
63
+ # change to an account/role
64
+ asp my-aws-role
65
+
66
+ # open main page of the role/account
67
+ console
68
+ # open ec2 page of the role/account
69
+ console ec2
70
+ # open lambda page of the role/account in us-west-2
71
+ console lambda -r us-west-2
72
+ # open a service page filtered by search terms (multiple words are joined)
73
+ console lambda my-function
74
+ console logs /aws/lambda/my
75
+ console cf my stack
76
+ # open instance id page of the role/account in
77
+ # whatever region that instance is in
78
+ console i-0123456789abcdef
79
+ # open an S3 bucket, prefix, or object
80
+ console s3://my-bucket/some/prefix/
81
+ # open a resource by name (log group, S3 bucket, EC2 Name tag,
82
+ # CloudFormation stack, or Lambda function)
83
+ console my-function
84
+ # open the console page for the resource the ARN points to
85
+ console arn:aws:ec2:us-east-1:012345678967:instance/i-0123456789abcdef
86
+ # force a new federated sign-in (resets the session cache)
87
+ console -f
88
+ ```
89
+
90
+ **Options:**
91
+
92
+ | Flag | Description |
93
+ | ----------------------- | ----------------------------------------------------------------- |
94
+ | `-r`, `--region <name>` | Region to open the console in; also added to the searched regions |
95
+ | `-f`, `--force` | Reset the session cache and force a new federated sign-in |
96
+
97
+ **Resolution order:**
98
+
99
+ 1. **ARN** — if the first argument parses as an ARN
100
+ 2. **Service** — if the first argument is a known service name or alias
101
+ 3. **Resource id** — if the first argument matches a known id pattern
102
+ 4. **Resource name** — looked up in parallel across all name-resolving services; the first match in priority order wins: CloudWatch log group → S3 bucket → EC2 `Name` tag → CloudFormation stack → Lambda function
103
+
104
+ **Supported services** (aliases after the `/`):
105
+
106
+ | Service | Names | Search terms |
107
+ | ---------------------- | ----------------------------------------- | ------------ |
108
+ | API Gateway | `apigateway` / `api` | |
109
+ | Artifact | `artifact` | |
110
+ | Athena | `athena` | |
111
+ | Batch | `batch` / `job` / `jobs` | |
112
+ | Bedrock | `bedrock` / `br` | |
113
+ | CloudFormation | `cloudformation` / `cf` | ✓ |
114
+ | CloudFront | `cloudfront` / `front` | |
115
+ | CloudHSM | `cloudhsm` / `hsm` | |
116
+ | CloudTrail | `cloudtrail` / `ct` | |
117
+ | CloudWatch | `cloudwatch` / `cw` | |
118
+ | CloudWatch Logs | `logs` | ✓ |
119
+ | Cognito | `cognito` / `cn` | |
120
+ | Config | `config` / `cfg` | |
121
+ | Control Tower | `controltower` | |
122
+ | Cost Management | `cost` | |
123
+ | DataSync | `datasync` / `ds` | |
124
+ | DynamoDB | `dynamodb` / `dynamo` / `dyn` | |
125
+ | EC2 instances | `ec2` | ✓ |
126
+ | EC2 AMIs (owned by me) | `ami` | ✓ |
127
+ | ECR | `ecr` / `docker` | |
128
+ | ECS | `ecs` / `cluster` / `task` / `tasks` | |
129
+ | EFS | `efs` | |
130
+ | EKS | `eks` | |
131
+ | Elastic Beanstalk | `elasticbeanstalk` / `bean` | |
132
+ | Elastic Load Balancing | `elb` / `alb` | |
133
+ | EventBridge | `eventbridge` / `eb` | |
134
+ | FSx | `fsx` | |
135
+ | Glue | `glue` | |
136
+ | GuardDuty | `guardduty` / `guard` | |
137
+ | IAM | `iam` | |
138
+ | Inspector | `inspector` | |
139
+ | KMS | `kms` | |
140
+ | Lambda | `lambda` | ✓ |
141
+ | Lex | `lex` | |
142
+ | Lightsail | `lightsail` / `ls` | |
143
+ | Marketplace | `marketplace` / `market` / `tennex` | ✓ |
144
+ | Polly | `polly` | |
145
+ | RDS | `rds` | |
146
+ | Route 53 | `route53` / `53` | |
147
+ | S3 | `s3` | |
148
+ | SageMaker | `sagemaker` / `sage` | |
149
+ | Scheduler | `scheduler` / `sch` | |
150
+ | Secrets Manager | `secretsmanager` / `secretmanager` / `sm` | |
151
+ | Security groups | `sg` | ✓ |
152
+ | SNS | `sns` | |
153
+ | SQS | `sqs` | |
154
+ | Step Functions | `step` | |
155
+ | Storage Gateway | `storagegateway` / `sgw` | |
156
+ | Support | `support` | |
157
+ | Systems Manager | `ssm` | |
158
+ | SSM Parameter Store | `parameter` / `ps` | ✓ |
159
+ | VPC | `vpc` | |
160
+ | VPC subnets | `subnet` | |
161
+ | VPC network ACLs | `acl` / `nacl` | |
162
+ | VPC Elastic IPs | `elasticip` / `eni` | |
163
+ | VPC route tables | `routetable` / `routes` | |
164
+ | VPC internet gateways | `internetgateway` / `internet` / `igw` | |
165
+ | VPC NAT gateways | `nat` | |
166
+ | VPC endpoints | `endpoints` / `end` | |
167
+ | VPC transit gateways | `transitgateway` / `transit` / `tgw` | |
168
+
169
+ `tennex` opens a Marketplace search for "tennex". Cost Management and Marketplace always open in `us-east-1`.
170
+
171
+ **Supported resource ids:** `i-*` (EC2 instance), `sg-*` (security group), `ami-*`, `lt-*` (launch template), `vol-*` (EBS volume), `snap-*` (EBS snapshot), `eni-*` (network interface), `s3://bucket[/key]`
172
+
173
+ **Supported ARNs:** `ec2` (instance), `lambda` (function), `logs` (log group, log stream), `s3` (bucket, prefix, object)
174
+
175
+ **Cross-account ARNs:** if an ARN's account differs from the current one, `console` switches to the first profile in your AWS config whose `role_arn` is in that account.
176
+
177
+ **Regions:** ids and names are searched across `us-east-1`, `us-east-2`, `us-west-1`, and `us-west-2`, plus the region passed with `-r`.
178
+
179
+ **Session cache:** federated session hashes are cached per profile for 59 minutes in `$XDG_STATE_HOME/console-sessions.json` (default `~/.local/state/console-sessions.json`). Use `-f` to reset it.
180
+
181
+ ---
182
+
183
+ ### `bing-wrapper`
184
+
185
+ A PTY wrapper that runs any command in a pseudo-terminal and plays a macOS system sound when a configurable output pattern is detected, and/or when the command finishes. Useful for long-running CLI tools (e.g. CDK deployments) that prompt for confirmation or take a while to complete.
186
+
187
+ **Requirements:** None
188
+
189
+ **Example Alias Usage:**
190
+
191
+ ```bash
192
+ # wraps cdk to play Frog.aiff when done and play Glass.aiff (default) on "(y/n)" prompts
193
+ alias cdk="bing-wrapper --end --pattern \"(y/n)\" --sound-end /System/Library/Sounds/Frog.aiff -- cdk"
194
+
195
+ # wraps nextflow to play a sound when done
196
+ alias nextflow="bing-wrapper --end -- nextflow"
197
+
198
+ # needed for autocomplete of bing-wrapper and the inner command
199
+ eval "$(bing-wrapper --autocomplete)"
200
+ ```
201
+
202
+ **Options:**
203
+
204
+ | Flag | Description | Default |
205
+ | ------------------------ | --------------------------------------------------------- | ------------ |
206
+ | `--end` | Play a sound when the command exits | off |
207
+ | `--pattern <text>` | Play a sound when `<text>` appears in output (repeatable) | none |
208
+ | `--sound-end <path>` | Sound file to play on exit | `Glass.aiff` |
209
+ | `--sound-pattern <path>` | Sound file to play on pattern match | `Glass.aiff` |
210
+ | `--sound-while <path>` | Sound file to play on loop while the command runs | none |
211
+
212
+ ---
213
+
214
+ ## Development
215
+
216
+ ```bash
217
+ pip install -e ".[dev]"
218
+ pytest
219
+ ```
220
+
221
+ Resolver tests live in `tests/console/resolvers/`, one module per service, and use `moto` to mock AWS.
@@ -0,0 +1,206 @@
1
+ [![PyPI version](https://img.shields.io/pypi/v/nate2-scripts)](https://pypi.org/project/nate2-scripts/)
2
+ [![License](https://img.shields.io/github/license/tennex-nwestfall/nate2-scripts)](https://github.com/tennex-nwestfall/nate2-scripts/blob/main/LICENSE)
3
+
4
+ # Nate2's Scripts
5
+
6
+ Utility scripts for AWS development on macOS.
7
+
8
+ To install run:
9
+
10
+ ```bash
11
+ pip install nate2-scripts
12
+ ```
13
+
14
+ To update run:
15
+
16
+ ```bash
17
+ pip install --upgrade nate2-scripts
18
+ ```
19
+
20
+ ## Scripts
21
+
22
+ ### `console`
23
+
24
+ Opens the AWS Management Console in your browser for a specific service, ARN, resource id, or resource name, using federated sign-in from your current AWS credentials. Supports multi-session via searching browser history sqlite databases.
25
+
26
+ **Requirements:**
27
+
28
+ - `AWS_PROFILE` set (e.g. via `asp`)
29
+ - `git config user.email` set — it is used as the `role_session_name` for every assume-role profile
30
+
31
+ **Example Alias:**
32
+
33
+ ```bash
34
+ # noglob is so that one can paste in logs arns that end with :*
35
+ # otherwise zsh tries to see the log arn as a glob and fails
36
+ alias co="noglob console"
37
+ # needed for autocomplete
38
+ eval "$(register-python-argcomplete console)"
39
+ ```
40
+
41
+ **Usage:**
42
+
43
+ ```bash
44
+ console [service | arn | id | name] [search ...] [-r REGION] [-f]
45
+ ```
46
+
47
+ ```bash
48
+ # change to an account/role
49
+ asp my-aws-role
50
+
51
+ # open main page of the role/account
52
+ console
53
+ # open ec2 page of the role/account
54
+ console ec2
55
+ # open lambda page of the role/account in us-west-2
56
+ console lambda -r us-west-2
57
+ # open a service page filtered by search terms (multiple words are joined)
58
+ console lambda my-function
59
+ console logs /aws/lambda/my
60
+ console cf my stack
61
+ # open instance id page of the role/account in
62
+ # whatever region that instance is in
63
+ console i-0123456789abcdef
64
+ # open an S3 bucket, prefix, or object
65
+ console s3://my-bucket/some/prefix/
66
+ # open a resource by name (log group, S3 bucket, EC2 Name tag,
67
+ # CloudFormation stack, or Lambda function)
68
+ console my-function
69
+ # open the console page for the resource the ARN points to
70
+ console arn:aws:ec2:us-east-1:012345678967:instance/i-0123456789abcdef
71
+ # force a new federated sign-in (resets the session cache)
72
+ console -f
73
+ ```
74
+
75
+ **Options:**
76
+
77
+ | Flag | Description |
78
+ | ----------------------- | ----------------------------------------------------------------- |
79
+ | `-r`, `--region <name>` | Region to open the console in; also added to the searched regions |
80
+ | `-f`, `--force` | Reset the session cache and force a new federated sign-in |
81
+
82
+ **Resolution order:**
83
+
84
+ 1. **ARN** — if the first argument parses as an ARN
85
+ 2. **Service** — if the first argument is a known service name or alias
86
+ 3. **Resource id** — if the first argument matches a known id pattern
87
+ 4. **Resource name** — looked up in parallel across all name-resolving services; the first match in priority order wins: CloudWatch log group → S3 bucket → EC2 `Name` tag → CloudFormation stack → Lambda function
88
+
89
+ **Supported services** (aliases after the `/`):
90
+
91
+ | Service | Names | Search terms |
92
+ | ---------------------- | ----------------------------------------- | ------------ |
93
+ | API Gateway | `apigateway` / `api` | |
94
+ | Artifact | `artifact` | |
95
+ | Athena | `athena` | |
96
+ | Batch | `batch` / `job` / `jobs` | |
97
+ | Bedrock | `bedrock` / `br` | |
98
+ | CloudFormation | `cloudformation` / `cf` | ✓ |
99
+ | CloudFront | `cloudfront` / `front` | |
100
+ | CloudHSM | `cloudhsm` / `hsm` | |
101
+ | CloudTrail | `cloudtrail` / `ct` | |
102
+ | CloudWatch | `cloudwatch` / `cw` | |
103
+ | CloudWatch Logs | `logs` | ✓ |
104
+ | Cognito | `cognito` / `cn` | |
105
+ | Config | `config` / `cfg` | |
106
+ | Control Tower | `controltower` | |
107
+ | Cost Management | `cost` | |
108
+ | DataSync | `datasync` / `ds` | |
109
+ | DynamoDB | `dynamodb` / `dynamo` / `dyn` | |
110
+ | EC2 instances | `ec2` | ✓ |
111
+ | EC2 AMIs (owned by me) | `ami` | ✓ |
112
+ | ECR | `ecr` / `docker` | |
113
+ | ECS | `ecs` / `cluster` / `task` / `tasks` | |
114
+ | EFS | `efs` | |
115
+ | EKS | `eks` | |
116
+ | Elastic Beanstalk | `elasticbeanstalk` / `bean` | |
117
+ | Elastic Load Balancing | `elb` / `alb` | |
118
+ | EventBridge | `eventbridge` / `eb` | |
119
+ | FSx | `fsx` | |
120
+ | Glue | `glue` | |
121
+ | GuardDuty | `guardduty` / `guard` | |
122
+ | IAM | `iam` | |
123
+ | Inspector | `inspector` | |
124
+ | KMS | `kms` | |
125
+ | Lambda | `lambda` | ✓ |
126
+ | Lex | `lex` | |
127
+ | Lightsail | `lightsail` / `ls` | |
128
+ | Marketplace | `marketplace` / `market` / `tennex` | ✓ |
129
+ | Polly | `polly` | |
130
+ | RDS | `rds` | |
131
+ | Route 53 | `route53` / `53` | |
132
+ | S3 | `s3` | |
133
+ | SageMaker | `sagemaker` / `sage` | |
134
+ | Scheduler | `scheduler` / `sch` | |
135
+ | Secrets Manager | `secretsmanager` / `secretmanager` / `sm` | |
136
+ | Security groups | `sg` | ✓ |
137
+ | SNS | `sns` | |
138
+ | SQS | `sqs` | |
139
+ | Step Functions | `step` | |
140
+ | Storage Gateway | `storagegateway` / `sgw` | |
141
+ | Support | `support` | |
142
+ | Systems Manager | `ssm` | |
143
+ | SSM Parameter Store | `parameter` / `ps` | ✓ |
144
+ | VPC | `vpc` | |
145
+ | VPC subnets | `subnet` | |
146
+ | VPC network ACLs | `acl` / `nacl` | |
147
+ | VPC Elastic IPs | `elasticip` / `eni` | |
148
+ | VPC route tables | `routetable` / `routes` | |
149
+ | VPC internet gateways | `internetgateway` / `internet` / `igw` | |
150
+ | VPC NAT gateways | `nat` | |
151
+ | VPC endpoints | `endpoints` / `end` | |
152
+ | VPC transit gateways | `transitgateway` / `transit` / `tgw` | |
153
+
154
+ `tennex` opens a Marketplace search for "tennex". Cost Management and Marketplace always open in `us-east-1`.
155
+
156
+ **Supported resource ids:** `i-*` (EC2 instance), `sg-*` (security group), `ami-*`, `lt-*` (launch template), `vol-*` (EBS volume), `snap-*` (EBS snapshot), `eni-*` (network interface), `s3://bucket[/key]`
157
+
158
+ **Supported ARNs:** `ec2` (instance), `lambda` (function), `logs` (log group, log stream), `s3` (bucket, prefix, object)
159
+
160
+ **Cross-account ARNs:** if an ARN's account differs from the current one, `console` switches to the first profile in your AWS config whose `role_arn` is in that account.
161
+
162
+ **Regions:** ids and names are searched across `us-east-1`, `us-east-2`, `us-west-1`, and `us-west-2`, plus the region passed with `-r`.
163
+
164
+ **Session cache:** federated session hashes are cached per profile for 59 minutes in `$XDG_STATE_HOME/console-sessions.json` (default `~/.local/state/console-sessions.json`). Use `-f` to reset it.
165
+
166
+ ---
167
+
168
+ ### `bing-wrapper`
169
+
170
+ A PTY wrapper that runs any command in a pseudo-terminal and plays a macOS system sound when a configurable output pattern is detected, and/or when the command finishes. Useful for long-running CLI tools (e.g. CDK deployments) that prompt for confirmation or take a while to complete.
171
+
172
+ **Requirements:** None
173
+
174
+ **Example Alias Usage:**
175
+
176
+ ```bash
177
+ # wraps cdk to play Frog.aiff when done and play Glass.aiff (default) on "(y/n)" prompts
178
+ alias cdk="bing-wrapper --end --pattern \"(y/n)\" --sound-end /System/Library/Sounds/Frog.aiff -- cdk"
179
+
180
+ # wraps nextflow to play a sound when done
181
+ alias nextflow="bing-wrapper --end -- nextflow"
182
+
183
+ # needed for autocomplete of bing-wrapper and the inner command
184
+ eval "$(bing-wrapper --autocomplete)"
185
+ ```
186
+
187
+ **Options:**
188
+
189
+ | Flag | Description | Default |
190
+ | ------------------------ | --------------------------------------------------------- | ------------ |
191
+ | `--end` | Play a sound when the command exits | off |
192
+ | `--pattern <text>` | Play a sound when `<text>` appears in output (repeatable) | none |
193
+ | `--sound-end <path>` | Sound file to play on exit | `Glass.aiff` |
194
+ | `--sound-pattern <path>` | Sound file to play on pattern match | `Glass.aiff` |
195
+ | `--sound-while <path>` | Sound file to play on loop while the command runs | none |
196
+
197
+ ---
198
+
199
+ ## Development
200
+
201
+ ```bash
202
+ pip install -e ".[dev]"
203
+ pytest
204
+ ```
205
+
206
+ Resolver tests live in `tests/console/resolvers/`, one module per service, and use `moto` to mock AWS.
@@ -4,8 +4,9 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nate2-scripts"
7
- version = "1.0.3"
7
+ version = "2.0.1"
8
8
  description = "Utility scripts for AWS development on macOS"
9
+ readme = "README.md"
9
10
  requires-python = ">=3.11"
10
11
  dependencies = [
11
12
  "argcomplete",
@@ -22,5 +23,18 @@ packages = ["src/nate2_scripts"]
22
23
  [tool.hatch.build.targets.wheel.force-include]
23
24
  "src/nate2_scripts/bing_wrapper/autocomplete.sh" = "nate2_scripts/bing_wrapper/autocomplete.sh"
24
25
 
26
+ [project.optional-dependencies]
27
+ dev = [
28
+ "boto3-stubs[essential]",
29
+ "moto[all]",
30
+ "pytest",
31
+ ]
32
+
33
+ [tool.pytest.ini_options]
34
+ testpaths = ["tests"]
35
+ # Resolver test modules are named after the service they cover (s3.py, logs.py,
36
+ # ...) rather than test_*.py, so widen collection to any module under tests/.
37
+ python_files = ["*.py"]
38
+
25
39
  [project.urls]
26
40
  Homepage = "https://github.com/tennex-nwestfall/nate2-scripts"
@@ -1,5 +1,6 @@
1
1
  """PTY wrapper for cdk that plays a sound when (y/n) prompts appear."""
2
2
 
3
+ import argparse
3
4
  import fcntl
4
5
  import os
5
6
  import select
@@ -10,7 +11,6 @@ import sys
10
11
  import termios
11
12
  import threading
12
13
  import tty
13
- import argparse
14
14
 
15
15
  # _PATTERN = b"(y/n)"
16
16
  # _WINDOW = len(_PATTERN) * 2
@@ -73,7 +73,9 @@ def run(args: argparse.Namespace) -> None:
73
73
  return
74
74
 
75
75
  if args.sound_while:
76
- _sound_while_thread = threading.Thread(target=_play_sound_while_loop, daemon=True)
76
+ _sound_while_thread = threading.Thread(
77
+ target=_play_sound_while_loop, daemon=True
78
+ )
77
79
  _sound_while_thread.start()
78
80
 
79
81
  # Propagate terminal resizes to the child (also sends SIGWINCH to it).