HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/codedeploy/__pycache__/register.cpython-36.pyc
3

�T_�@sTddlZddlmZddlmZddlmZmZmZm	Z	m
Z
mZGdd�de�ZdS)�N)�BasicCommand)�DEFAULT_CONFIG_FILE)�validate_region�validate_instance_name�
validate_tags�validate_iam_user_arn�INSTANCE_NAME_ARG�IAM_USER_ARN_ARGc@s�eZdZdZdZdddddd�d	ddd�d
�d�d�Zed
dddedd�egZdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd �Zd!S)"�Register�registeraCreates an IAM user for the on-premises instance, if not provided, and saves the user's credentials to an on-premises instance configuration file; registers the on-premises instance with AWS CodeDeploy; and optionally adds tags to the on-premises instance.Zarray�objectzThe tag key.�stringT)�description�type�requiredzThe tag value.)ZKeyZValue)rZ
properties)r�items�tagsz--tags <value>F�+zFOptional. The list of key/value pairs to tag the on-premises instance.)�nameZsynopsisr�nargsZschemaZ	help_textcCs|}|j|_t||�t|�t|�t|�|jjd|j|j|j	d�|_
|jjd|jd�|_y^|js�|j
|�|j|�|j|�|j|�|j|�|jr�|j|�tjjdjt��Wn>tk
r�}z"tjj�tjjdj|��WYdd}~XnXdS)N�
codedeploy)�region_name�endpoint_urlZverify�iam)rz�Copy the on-premises configuration file named {0} to the on-premises instance, and run the following command on the on-premises instance to install and configure the AWS CodeDeploy Agent:
aws deploy install --config-file {0}
z�ERROR
{0}
Register the on-premises instance by following the instructions in "Configure Existing On-Premises Instances by Using AWS CodeDeploy" in the AWS CodeDeploy User Guide.
)Z_sessionZsessionrrrrZ
create_client�regionrZ
verify_sslrr�iam_user_arn�_create_iam_user�_create_access_key�_create_user_policy�_create_config�_register_instancer�	_add_tags�sys�stdout�write�formatr�	Exception�flush�stderr)�selfZparsed_argsZparsed_globals�params�e�r,�/usr/lib/python3.6/register.py�	_run_mainDs>







zRegister._run_maincCsLtjjd�|j|_|jjd|jd�}|dd|_tjjdj|j��dS)NzCreating the IAM user... z/AWS/CodeDeploy/)ZPath�UserNameZUserZArnzDONE
IamUserArn: {0}
)	r"r#r$�
instance_name�	user_namerZcreate_userrr%)r)r*�responser,r,r-rts
zRegister._create_iam_usercCsTtjjd�|jj|jd�}|dd|_|dd|_tjjdj|j|j��dS)Nz$Creating the IAM user access key... )r/Z	AccessKeyZAccessKeyIdZSecretAccessKeyz+DONE
AccessKeyId: {0}
SecretAccessKey: {1}
)	r"r#r$rZcreate_access_keyr1�
access_key_id�secret_access_keyr%)r)r*r2r,r,r-r�s
zRegister._create_access_keycCsLtjjd�d|_d|_|jj|j|j|jd�tjjdj|j|j��dS)Nz Creating the IAM user policy... zcodedeploy-agentz�{
    "Version": "2012-10-17",
    "Statement": [ {
        "Action": [ "s3:Get*", "s3:List*" ],
        "Effect": "Allow",
        "Resource": "*"
    } ]
})r/Z
PolicyNameZPolicyDocumentz)DONE
PolicyName: {0}
PolicyDocument: {1}
)	r"r#r$Zpolicy_nameZpolicy_documentrZput_user_policyr1r%)r)r*r,r,r-r�s	
zRegister._create_user_policyc
CsVtjjdjt��ttd��$}|jdj|j|j|j|j	��WdQRXtjjd�dS)NzACreating the on-premises instance configuration file named {0}...�wzT---
region: {0}
iam_user_arn: {1}
aws_access_key_id: {2}
aws_secret_access_key: {3}
zDONE
)
r"r#r$r%r�openrrr3r4)r)r*�fr,r,r-r�szRegister._create_configcCs0tjjd�|jj|j|jd�tjjd�dS)Nz(Registering the on-premises instance... )ZinstanceNameZ
iamUserArnzDONE
)r"r#r$rZregister_on_premises_instancer0r)r)r*r,r,r-r �s

zRegister._register_instancecCs2tjjd�|jj|j|jgd�tjjd�dS)Nz+Adding tags to the on-premises instance... )rZ
instanceNameszDONE
)r"r#r$rZ!add_tags_to_on_premises_instancesrr0)r)r*r,r,r-r!�s
zRegister._add_tagsN)�__name__�
__module__�__qualname__�NAMEZDESCRIPTIONZTAGS_SCHEMArr	Z	ARG_TABLEr.rrrrr r!r,r,r,r-r
s20r
)
r"Zawscli.customizations.commandsrZ(awscli.customizations.codedeploy.systemsrZ&awscli.customizations.codedeploy.utilsrrrrrr	r
r,r,r,r-�<module>s