code: def create_instances_struct(
      disk_size: int,
      image_id: str,
      instance_type: str,
      iam_instance_profile_arn: Optional[str],
      user_data: str,
      tags: List[Dict[str, str]],
      security_group_id: str,
      spot: bool,
  ) -> Dict[str, Any]:
      struct = dict(
          BlockDeviceMappings=[
              {
                  "DeviceName": "/dev/sda1",
                  "Ebs": {
                      "VolumeSize": disk_size,
                      "VolumeType": "gp2",
                  },
              }
          ],
          ImageId=image_id,
          InstanceType=instance_type,
          MinCount=1,
          MaxCount=1,
          UserData=user_data,
          TagSpecifications=[
              {
                  "ResourceType": "instance",
                  "Tags": tags,
              },
          ],
          SecurityGroupIds=[security_group_id],
      )
      if iam_instance_profile_arn:
          struct["IamInstanceProfile"] = {
              "Arn": iam_instance_profile_arn
          }
      if spot:
          struct["InstanceMarketOptions"] = {
              "MarketType": "spot",
              "SpotOptions": {
                  "SpotInstanceType": "one-time",
                  "InstanceInterruptionBehavior": "terminate",
              },
          }
      return struct
  
file_path: dstack/src/dstack/_internal/core/backends/aws/resources.py
imports: import json
  from typing import Any, Dict, List, Optional
  import botocore.client
  import botocore.exceptions
  import dstack.version
  from dstack._internal.core.errors import ResourceNotFoundError
label_desc: Use image node_id 5 for calling a global function with example usage: create_instances_struct(disk_size, image_id, instance_type, iam_instance_profile_arn, user_data, tags, security_group_id, spot) and returns: struct