    # File lib/fog/aws/models/compute/server.rb, line 146
            def save
              raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
              requires :image_id

              options = {
                'BlockDeviceMapping'          => block_device_mapping,
                'ClientToken'                 => client_token,
                'IamInstanceProfile.Arn'      => @iam_instance_profile_arn,
                'IamInstanceProfile.Name'     => @iam_instance_profile_name,
                'InstanceInitiatedShutdownBehavior' => instance_initiated_shutdown_behavior,
                'InstanceType'                => flavor_id,
                'KernelId'                    => kernel_id,
                'KeyName'                     => key_name,
                'Monitoring.Enabled'          => monitoring,
                'Placement.AvailabilityZone'  => availability_zone,
                'Placement.GroupName'         => placement_group,
                'Placement.Tenancy'           => tenancy,
                'PrivateIpAddress'            => private_ip_address,
                'RamdiskId'                   => ramdisk_id,
                'SecurityGroup'               => groups,
                'SecurityGroupId'             => security_group_ids,
                'SubnetId'                    => subnet_id,
                'UserData'                    => user_data,
              }
              options.delete_if {|key, value| value.nil?}

              # If subnet is defined then this is a Virtual Private Cloud.
              # subnet & security group cannot co-exist. Attempting to specify
              # both subnet and groups will cause an error.  Instead please make
              # use of Security Group Ids when working in a VPC.
              if subnet_id
                options.delete('SecurityGroup')
              else
                options.delete('SubnetId')
              end

              data = connection.run_instances(image_id, 1, 1, options)
              merge_attributes(data.body['instancesSet'].first)

              if tags = self.tags
                # expect eventual consistency
                Fog.wait_for { self.reload rescue nil }
                for key, value in (self.tags = tags)
                  connection.tags.create(
                    :key          => key,
                    :resource_id  => self.identity,
                    :value        => value
                  )
                end
              end

              true
            end