in packages/aws-rfdk/lib/deadline/scripts/python/configure_identity_registration_settings.py [0:0]
def parse_args(args):
"""
Parses all command line arguments and convert them into named tuples
:param args: A list of command line arguments
:return: A configuration object containing the parsed arguments
"""
def _secret(value):
"""
A type function for converting args that represent secrets into a named Tuple
:param value: The string representing the argument
:return: AwsSecret based on the value
:exception argparse.ArgumentTypeError: if the argument cannot be converted properly.
"""
match = SECRET_ARN_RE.match(value)
if match:
named_groups = match.groupdict()
return AwsSecret(arn=value,region=named_groups["Region"])
raise argparse.ArgumentTypeError('Given argument "%s" is not a valid secret' % value)
def _source_subnet(value):
"""
A type function for converting args that represent source subnets
"""
match = SOURCE_SUBNET_RE.match(value)
if match:
named_groups = match.groupdict()
subnet_id = named_groups['SubnetID']
role = named_groups['Role']
registration_status = named_groups['RegistrationStatus']
return SourceSubnet(
role = role,
registration_status = registration_status,
subnet_id = subnet_id
)
raise argparse.ArgumentTypeError('Given argument "%s" is not a valid source subnet' % value)
parser = argparse.ArgumentParser(description="Configures Deadline Secrets Management identity registration settings")
parser.add_argument(
'--credentials',
type = _secret,
required = True,
help = 'Specifies Deadline Secrets Management admin credentials. This must be an AWS Secrets Manager ' \
'secret arn',
)
parser.add_argument(
'--region',
required = True,
help = 'The region where the Repository, Render Queue, and Clients reside',
)
parser.add_argument(
'--connection-subnet',
action = 'append',
help = 'Specifies one or more subnet IDs that the Render Queue\'s load balancer will connect from',
)
parser.add_argument(
'--source-subnet',
type = _source_subnet,
action = 'append',
help = 'Specifies one or more source subnets that Deadline Clients will connect from and their role and ' \
'registration status to be applied. This should be a comma-separated string where the first two ' \
'elements are the role and status respectively and additional elements are subnet IDs'
)
return parser.parse_args(args)