@SdkInternalApi
    final RegisterInstanceResult executeRegisterInstance(RegisterInstanceRequest registerInstanceRequest) {

        ExecutionContext executionContext = createExecutionContext(registerInstanceRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<RegisterInstanceRequest> request = null;
        Response<RegisterInstanceResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new RegisterInstanceRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(registerInstanceRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "OpsWorks");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "RegisterInstance");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            HttpResponseHandler<AmazonWebServiceResponse<RegisterInstanceResult>> responseHandler = protocolFactory.createResponseHandler(
                    new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new RegisterInstanceResultJsonUnmarshaller());
            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
Registers instances that were created outside of OpsWorks Stacks with a specified stack.
</p>
<note>
<p>
We do not recommend using this action to register instances. The complete registration operation includes two
tasks: installing the OpsWorks Stacks agent on the instance, and registering the instance with the stack.
<code>RegisterInstance</code> handles only the second step. You should instead use the CLI <code>register</code>
command, which performs the entire registration operation. For more information, see <a
href="https://docs.aws.amazon.com/opsworks/latest/userguide/registered-instances-register.html"> Registering an
Instance with an OpsWorks Stacks Stack</a>.
</p>
</note>
<p>
Registered instances have the same requirements as instances that are created by using the <a>CreateInstance</a>
API. For example, registered instances must be running a supported Linux-based operating system, and they must
have a supported instance type. For more information about requirements for instances that you want to register,
see <a href=
"https://docs.aws.amazon.com/opsworks/latest/userguide/registered-instances-register-registering-preparer.html">
Preparing the Instance</a>.
</p>
<p>
<b>Required Permissions</b>: To use this action, an IAM user must have a Manage permissions level for the stack
or an attached policy that explicitly grants permissions. For more information on user permissions, see <a
href="https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html">Managing User
Permissions</a>.
</p>

@param registerInstanceRequest
@return Result of the RegisterInstance operation returned by the service.
@throws ValidationException
        Indicates that a request was not valid.
@throws ResourceNotFoundException
        Indicates that a resource was not found.
@sample AWSOpsWorks.RegisterInstance
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/opsworks-2013-02-18/RegisterInstance" target="_top">AWS API
     Documentation</a>
aws-java-sdk-opsworks/src/main/java/com/amazonaws/services/opsworks/AWSOpsWorksClient.java