'Runs deployment or stack commands. For more information, see
`Deploying Apps`_ and `Run Stack Commands`_.
**Required Permissions**: To use this action, an IAM user must
have a Deploy or Manage permissions level for the stack, or an
attached policy that explicitly grants permissions. For more
information on user permissions, see `Managing User
Permissions`_.
:type stack_id: string
:param stack_id: The stack ID.
:type app_id: string
:param app_id: The app ID. This parameter is required for app
deployments, but not for other deployment commands.
:type instance_ids: list
:param instance_ids: The instance IDs for the deployment targets.
:type command: dict
:param command: A `DeploymentCommand` object that specifies the
deployment command and any associated arguments.
:type comment: string
:param comment: A user-defined comment.
:type custom_json: string
:param custom_json: A string that contains user-defined, custom JSON.
It is used to override the corresponding default stack
configuration JSON values. The string should be in the following
format and must escape characters such as \'"\'.:
`"{"key1": "value1", "key2": "value2",...}"`
For more information on custom JSON, see `Use Custom JSON to Modify the
Stack Configuration JSON`_.'

def create_deployment(self, stack_id, command, app_id=None, instance_ids=None, comment=None, custom_json=None):

    params = {'StackId': stack_id, 'Command': command}
    if (app_id is not None):
        params['AppId'] = app_id
    if (instance_ids is not None):
        params['InstanceIds'] = instance_ids
    if (comment is not None):
        params['Comment'] = comment
    if (custom_json is not None):
        params['CustomJson'] = custom_json
    return self.make_request(action='CreateDeployment', body=json.dumps(params))
