HEX
Server: Apache
System: Linux pdx1-shared-a3-07 6.6.116-grsec-jammy-dirty #1 SMP Sat Nov 8 00:02:42 UTC 2025 x86_64
User: dh_2qpcdp (6386943)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/codedeploy/__pycache__/register.cpython-310.pyc
o

.&�a�@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.�array�objectzThe tag key.�stringT)�description�type�requiredzThe tag value.)�Key�Value)r�
properties)r�items�tagsz--tags <value>F�+zFOptional. The list of key/value pairs to tag the on-premises instance.)�name�synopsisr�nargs�schema�	help_textc
Cs|}|j|_t||�t|�t|�t|�|jjd|j|j|j	d�|_
|jjd|jd�|_z0|jsG|�
|�|�|�|�|�|�|�|�|�|jrT|�|�tj�d�t��WdSty�}ztj��tj�d�|��WYd}~dSd}~ww)N�
codedeploy)�region_name�endpoint_url�verify�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.
)�_session�sessionrrrr�
create_client�regionr�
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)�self�parsed_args�parsed_globals�params�e�r:�K/usr/lib/python3/dist-packages/awscli/customizations/codedeploy/register.py�	_run_mainDsN
��





�
�	
���zRegister._run_maincCsLtj�d�|j|_|jjd|jd�}|dd|_tj�d�|j��dS)NzCreating the IAM user... z/AWS/CodeDeploy/)�Path�UserName�User�ArnzDONE
IamUserArn: {0}
)	r.r/r0�
instance_name�	user_namer!�create_userr'r1�r5r8�responser:r:r;r(ts���zRegister._create_iam_usercCsTtj�d�|jj|jd�}|dd|_|dd|_tj�d�|j|j��dS)Nz$Creating the IAM user access key... )r>�	AccessKey�AccessKeyId�SecretAccessKeyz+DONE
AccessKeyId: {0}
SecretAccessKey: {1}
)	r.r/r0r!�create_access_keyrB�
access_key_id�secret_access_keyr1rDr:r:r;r)�s���zRegister._create_access_keycCsLtj�d�d|_d|_|jj|j|j|jd�tj�d�|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>�
PolicyName�PolicyDocumentz)DONE
PolicyName: {0}
PolicyDocument: {1}
)	r.r/r0�policy_name�policy_documentr!�put_user_policyrBr1�r5r8r:r:r;r*�s �
���zRegister._create_user_policyc	Csjtj�d�t��ttd��}|�d�|j|j|j|j	��Wd�n1s(wYtj�d�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}
�DONE
)
r.r/r0r1r�openr%r'rJrK)r5r8�fr:r:r;r+�s ����
zRegister._create_configcCs0tj�d�|jj|j|jd�tj�d�dS)Nz(Registering the on-premises instance... )�instanceName�
iamUserArnrS)r.r/r0r�register_on_premises_instancerAr'rQr:r:r;r,�s�zRegister._register_instancecCs2tj�d�|jj|j|jgd�tj�d�dS)Nz+Adding tags to the on-premises instance... )r�
instanceNamesrS)r.r/r0r�!add_tags_to_on_premises_instancesrrArQr:r:r;r-�s�zRegister._add_tagsN)�__name__�
__module__�__qualname__�NAME�DESCRIPTION�TAGS_SCHEMArr	�	ARG_TABLEr<r(r)r*r+r,r-r:r:r:r;r
sD��������0r
)
r.�awscli.customizations.commandsr�(awscli.customizations.codedeploy.systemsr�&awscli.customizations.codedeploy.utilsrrrrrr	r
r:r:r:r;�<module>s