Skip to content

Commit abfebd1

Browse files
Force developer to type in app client environment
1 parent 8ad0845 commit abfebd1

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

backend/compact-connect/app_clients/bin/create_app_client.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ def get_user_input():
125125
"""Get user input for app client configuration."""
126126
print('=== App Client Configuration ===\n')
127127

128+
# Get environment
129+
while True:
130+
try:
131+
print('Valid environments: test, beta, prod')
132+
environment = input('Enter the environment: ').strip().lower()
133+
if environment not in ['test', 'beta', 'prod']:
134+
raise ValueError('Invalid environment. Must be one of: test, beta, prod')
135+
break
136+
except ValueError as e:
137+
print(f'Error: {e}')
138+
128139
# Get client name
129140
client_name = input("Enter the app client name (e.g., 'example-ky-app-client-v1'): ").strip()
130141
if not client_name:
@@ -183,7 +194,7 @@ def get_user_input():
183194
print('Configuration cancelled.')
184195
sys.exit(0)
185196

186-
return {'clientName': client_name, 'compact': compact, 'state': state, 'scopes': deduped_scopes}
197+
return {'environment': environment, 'clientName': client_name, 'compact': compact, 'state': state, 'scopes': deduped_scopes}
187198

188199

189200
def create_app_client(user_pool_id, config):
@@ -293,20 +304,18 @@ def print_email_template(environment, compact, state):
293304

294305
def main():
295306
parser = argparse.ArgumentParser(description='Create AWS Cognito app client interactively')
296-
parser.add_argument(
297-
'-e', '--environment', required=True, choices=['test', 'beta', 'prod'], help='Environment (test, beta, or prod)'
298-
)
299307
parser.add_argument('-u', '--user-pool-id', required=True, help='AWS Cognito User Pool ID')
300308

301309
args = parser.parse_args()
302310

303311
try:
304-
print(f'Creating app client for {args.environment} environment...')
305312
print(f'User Pool ID: {args.user_pool_id}\n')
306313

307-
# Get configuration from user input
314+
# Get configuration from user input (including environment)
308315
config = get_user_input()
309316

317+
print(f'\nCreating app client for {config["environment"]} environment...')
318+
310319
# Create the app client
311320
response = create_app_client(args.user_pool_id, config)
312321

@@ -328,7 +337,7 @@ def main():
328337
print_credentials(client_id, client_secret)
329338

330339
# Print email template
331-
print_email_template(args.environment, config['compact'], config['state'])
340+
print_email_template(config['environment'], config['compact'], config['state'])
332341

333342
print('\n📝 Remember to add this app client to your external registry!')
334343

0 commit comments

Comments
 (0)