예제 #1
0
    def _run_main(self, parsed_args, parsed_globals):
        params = parsed_args
        params.session = self._session
        validate_region(params, parsed_globals)
        validate_instance_name(params)
        validate_tags(params)
        validate_iam_user_arn(params)

        self.codedeploy = self._session.create_client(
            'codedeploy',
            region_name=params.region,
            endpoint_url=parsed_globals.endpoint_url,
            verify=parsed_globals.verify_ssl
        )
        self.iam = self._session.create_client(
            'iam',
            region_name=params.region
        )

        try:
            if not params.iam_user_arn:
                self._create_iam_user(params)
                self._create_access_key(params)
                self._create_user_policy(params)
                self._create_config(params)
            self._register_instance(params)
            if params.tags:
                self._add_tags(params)
            sys.stdout.write(
                '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:\n'
                'aws deploy install --config-file {0}\n'.format(
                    DEFAULT_CONFIG_FILE
                )
            )
        except Exception as e:
            sys.stdout.flush()
            sys.stderr.write(
                'ERROR\n'
                '{0}\n'
                '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.\n'.format(e)
            )
예제 #2
0
    def _run_main(self, parsed_args, parsed_globals):
        params = parsed_args
        params.session = self._session
        validate_region(params, parsed_globals)
        validate_instance_name(params)
        validate_tags(params)
        validate_iam_user_arn(params)

        self.codedeploy = self._session.create_client(
            'codedeploy',
            region_name=params.region,
            endpoint_url=parsed_globals.endpoint_url,
            verify=parsed_globals.verify_ssl)
        self.iam = self._session.create_client('iam',
                                               region_name=params.region)

        try:
            if not params.iam_user_arn:
                self._create_iam_user(params)
                self._create_access_key(params)
                self._create_user_policy(params)
                self._create_config(params)
            self._register_instance(params)
            if params.tags:
                self._add_tags(params)
            sys.stdout.write(
                '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:\n'
                'aws deploy install --config-file {0}\n'.format(
                    DEFAULT_CONFIG_FILE))
        except Exception as e:
            sys.stdout.flush()
            sys.stderr.write(
                'ERROR\n'
                '{0}\n'
                '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.\n'.format(e))
            return 255
        return 0
예제 #3
0
 def test_validate_iam_user_arn_throws_on_invalid_arn_pattern(self):
     self.params.iam_user_arn = 'invalid-arn-pattern'
     error_msg = 'Invalid IAM user ARN.'
     with self.assertRaisesRegexp(ParamValidationError, error_msg):
         validate_iam_user_arn(self.params)
예제 #4
0
 def test_validate_iam_user_arn(self):
     self.params.iam_user_arn = self.iam_user_arn
     validate_iam_user_arn(self.params)
예제 #5
0
 def test_validate_iam_user_arn_throws_on_invalid_arn_pattern(self):
     self.params.iam_user_arn = 'invalid-arn-pattern'
     with self.assertRaisesRegexp(ValueError, 'Invalid IAM user ARN.'):
         validate_iam_user_arn(self.params)
예제 #6
0
 def test_validate_iam_user_arn_throws_on_invalid_arn_pattern(self):
     self.params.iam_user_arn = 'invalid-arn-pattern'
     with self.assertRaisesRegexp(ValueError, 'Invalid IAM user ARN.'):
         validate_iam_user_arn(self.params)
예제 #7
0
 def test_validate_iam_user_arn(self):
     self.params.iam_user_arn = self.iam_user_arn
     validate_iam_user_arn(self.params)