o .&a@sddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZeeZGdd d e ZdS) N)Config)Template) yaml_dump) exceptions) BasicCommand) S3Uploaderc @seZdZdZdZeddZddddd dd dd d d ddd ddd dddddddddddddiddidddgZdd Z d!d"Z d#d$Z d%S)&PackageCommandzSuccessfully packaged artifacts and wrote output template to file {output_file_name}. Execute the following command to deploy the packaged template aws cloudformation deploy --template-file {output_file_path} --stack-name packagecloudformationz_package_description.rstz template-fileTz;The path where your AWS CloudFormation template is located.)namerequired help_textz s3-bucketzhThe name of the S3 bucket where this command uploads the artifacts that are referenced in your template.z s3-prefixzA prefix name that the command adds to the artifacts' name when it uploads them to the S3 bucket. The prefix name is a path name (folder name) for the S3 bucket.)r r z kms-key-idzfThe ID of an AWS KMS key that the command uses to encrypt artifacts that are at rest in the S3 bucket.zoutput-template-filezThe path to the file where the command writes the output AWS CloudFormation template. If you don't specify a path, the command writes the template to the standard output.zuse-json store_truezpIndicates whether to use JSON as the format for the output AWS CloudFormation template. YAML is used by default.)r actionr z force-uploadzIndicates whether to override existing files in the S3 bucket. Specify this flag to upload artifacts even if they match existing artifacts in the S3 bucket.metadatamaptypestring)rkeyvaluezXA map of metadata to attach to *ALL* the artifacts that are referenced in your template.)r cli_type_nameschemar c Cs|jjdtdd|j|jd}|j}tj|st j |d|j }t |||j |j|j|_|j|j_|j}|j}|||}tjd||||r^|jj|tj|d} tj| tjdS) Ns3s3v4)signature_version)config region_nameverify) template_path )output_file_nameoutput_file_pathr)_session create_clientrregion verify_ssl template_fileospathisfilerInvalidTemplatePathError s3_bucketr s3_prefix kms_key_id force_upload s3_uploaderrartifact_metadataoutput_template_fileuse_json_exportsysstdoutwrite write_outputMSG_PACKAGED_TEMPLATE_WRITTENformatabspathflush) self parsed_argsparsed_globals s3_clientrbucket output_filer2 exported_strmsgrDN/usr/lib/python3/dist-packages/awscli/customizations/cloudformation/package.py _run_main~s@        zPackageCommand._run_maincCs>t|t|j}|}|rtj|ddd}|St|}|S)NF)indent ensure_ascii)rr'getcwdr/exportjsondumpsr)r<rr2templateexported_templaterBrDrDrEr3szPackageCommand._exportcCsR|dur tj|dSt|d}||WddS1s"wYdS)Nw)r4r5r6open)r<r datafprDrDrEr7s    "zPackageCommand.write_outputN) __name__ __module__ __qualname__r8NAMEr FROM_FILE DESCRIPTION ARG_TABLErFr3r7rDrDrDrErsX        N& r)r'loggingr4rLbotocore.clientr6awscli.customizations.cloudformation.artifact_exporterr/awscli.customizations.cloudformation.yamlhelperr$awscli.customizations.cloudformationrawscli.customizations.commandsr awscli.customizations.s3uploaderr getLoggerrTLOGrrDrDrDrEs