@SdkInternalApi
    final ModifyInstancePlacementResult executeModifyInstancePlacement(ModifyInstancePlacementRequest modifyInstancePlacementRequest) {

        ExecutionContext executionContext = createExecutionContext(modifyInstancePlacementRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<ModifyInstancePlacementRequest> request = null;
        Response<ModifyInstancePlacementResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new ModifyInstancePlacementRequestMarshaller().marshall(super.beforeMarshalling(modifyInstancePlacementRequest));
                // 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, "EC2");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ModifyInstancePlacement");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

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

            StaxResponseHandler<ModifyInstancePlacementResult> responseHandler = new StaxResponseHandler<ModifyInstancePlacementResult>(
                    new ModifyInstancePlacementResultStaxUnmarshaller());

            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
Modifies the placement attributes for a specified instance. You can do the following:
</p>
<ul>
<li>
<p>
Modify the affinity between an instance and a <a
href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-overview.html">Dedicated Host</a>. When
affinity is set to <code>host</code> and the instance is not associated with a specific Dedicated Host, the next
time the instance is started, it is automatically associated with the host on which it lands. If the instance is
restarted or rebooted, this relationship persists.
</p>
</li>
<li>
<p>
Change the Dedicated Host with which an instance is associated.
</p>
</li>
<li>
<p>
Change the instance tenancy of an instance.
</p>
</li>
<li>
<p>
Move an instance to or from a <a
href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html">placement group</a>.
</p>
</li>
</ul>
<p>
At least one attribute for affinity, host ID, tenancy, or placement group name must be specified in the request.
Affinity and tenancy can be modified in the same request.
</p>
<p>
To modify the host ID, tenancy, placement group, or partition for an instance, the instance must be in the
<code>stopped</code> state.
</p>

@param modifyInstancePlacementRequest
@return Result of the ModifyInstancePlacement operation returned by the service.
@sample AmazonEC2.ModifyInstancePlacement
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/ModifyInstancePlacement" target="_top">AWS
     API Documentation</a>
aws-java-sdk-ec2/src/main/java/com/amazonaws/services/ec2/AmazonEC2Client.java