in util/upload-cookbook.py [0:0]
def _parse_args():
global _credentials
global _main_region
parser = argparse.ArgumentParser(description="Uploads cookbook to S3")
parser.add_argument(
"--regions",
type=str,
help='Valid Regions, can include "all", or comma separated list of regions',
required=True,
)
parser.add_argument(
"--unsupportedregions", type=str, help="Unsupported regions, comma separated", default="", required=False
)
parser.add_argument(
"--override",
action="store_true",
help="If override is false, the file will not be pushed if it already exists in the bucket",
default=False,
required=False,
)
parser.add_argument(
"--bucket", type=str, help="Buckets to upload to, defaults to [region]-aws-parallelcluster", required=False
)
parser.add_argument("--cookbook-archive-path", type=str, help="Cookbook archive path", required=True)
parser.add_argument(
"--dryrun", action="store_true", help="Doesn't push anything to S3, just outputs", default=False, required=False
)
parser.add_argument("--partition", type=str, help="commercial | china | govcloud", required=True)
parser.add_argument(
"--credential",
type=str,
action="append",
help="STS credential endpoint, in the format <region>,<endpoint>,<ARN>,<externalId>. "
"Could be specified multiple times",
required=False,
)
args = parser.parse_args()
if args.partition == "commercial":
_main_region = "us-east-1"
elif args.partition == "govcloud":
_main_region = "us-gov-west-1"
elif args.partition == "china":
_main_region = "cn-north-1"
else:
print("Unsupported partition {0}".format(args.partition))
exit(1)
if args.credential:
_credentials = [
tuple(credential_tuple.strip().split(","))
for credential_tuple in args.credential
if credential_tuple.strip()
]
if args.regions == "all":
args.regions = _get_all_aws_regions(_main_region)
else:
args.regions = [x.strip() for x in args.regions.split(",")]
args.unsupportedregions = [x.strip() for x in args.unsupportedregions.split(",")]
# Purging regions
args.regions = set(args.regions) - set(args.unsupportedregions)
# Adds all opt-in regions
for credential in _credentials:
args.regions.add(credential[0])
return args