From 7a4715f1b65ec6c26080727b99c012521dd2365f Mon Sep 17 00:00:00 2001 From: Thiery Ouattara Date: Mon, 2 Sep 2024 09:24:51 +0000 Subject: [PATCH] Update doc and add hcl example --- .web-docs/components/builder/bsu/README.md | 118 +++++++++++++++++- .../components/builder/bsusurrogate/README.md | 85 ++++++++++--- builder/bsu/builder.hcl2spec.go | 4 +- builder/bsusurrogate/builder.hcl2spec.go | 2 + builder/chroot/builder.go | 1 - builder/chroot/builder.hcl2spec.go | 4 +- docs/builders/bsu.mdx | 118 +++++++++++++++++- docs/builders/bsusurrogate.mdx | 85 ++++++++++--- 8 files changed, 372 insertions(+), 45 deletions(-) diff --git a/.web-docs/components/builder/bsu/README.md b/.web-docs/components/builder/bsu/README.md index 299979d..15c1e6a 100644 --- a/.web-docs/components/builder/bsu/README.md +++ b/.web-docs/components/builder/bsu/README.md @@ -62,8 +62,6 @@ builder. - `snapshot_id` (string) - The ID of the snapshot - - `virtual_name` (string) - The virtual device name. See the documentation on [Block Device Mapping](https://docs.outscale.com/en/userguide/Defining-Block-Device-Mappings.html) for more information - - `volume_size` (number) - The size of the volume, in GiB. Required if not specifying a `snapshot_id` - `volume_type` (string) - The volume type. `gp2` for General Purpose (SSD) volumes, `io1` for Provisioned IOPS (SSD) volumes, and `standard` for Magnetic volumes @@ -167,7 +165,19 @@ builder. - `owners` (array of strings) - Filters the images by their owner. You may specify one or more Outscale account IDs, "self" (which will use the account whose credentials you are using to run Packer). This option is required for security reasons. Example: + #### HCL + ```hcl + source_omi_filter { + filters = { + image-name = "image-name-in-account" + root-device-type = "ebs" # or "bsu" + virtualization-type = "hvm" + } + owners = ["339215505907"] + } + ``` + #### JSON ```json { "source_omi_filter": { @@ -250,7 +260,19 @@ builder. ## Basic Example Here is a basic example. You will need to provide access keys, and may need to change the OMIS IDs according to what images exist at the time the template is run: +#### HCL +```hcl +source "outscale-bsu" "basic-example" { + region = "us-east-1" + vm_type = "t2.micro" + source_omi = "ami-abcfd0283" + omi_name = "packer_osc_{{timestamp}}" + ssh_username = "outscale" + ssh_interface = "public_ip" +} +``` +#### JSON ```json { "variables": { @@ -290,9 +312,91 @@ You can use this information to access the VM as it is running. Here is an example using the optional OMIS block device mappings. Our configuration of `launch_block_device_mappings` will expand the root volume (`/dev/sda`) to 40gb during the build (up from the default of 8gb). With -`ami_block_device_mappings` Outscale will attach additional volumes `/dev/sdb` and +`omi_block_device_mappings` Outscale will attach additional volumes `/dev/sdb` and `/dev/sdc` when we boot a new VM of our OMI. +#### HCL +##### with `launch_block_device_mappings` +```hcl +// export osc_access_key=$YOURKEY +variable "osc_access_key" { + type = string + // default = "hardcoded_key" +} + +// export osc_secret_key=$YOURSECRETKEY +variable "osc_secret_key" { + type = string + // default = "hardcoded_secret_key" +} + +source "outscale-bsu" "basic-example" { + region = "us-east-1" + vm_type = "t2.micro" + source_omi = "ami-abcfd0283" + omi_name = "packer_osc_{{timestamp}}" + ssh_username = "outscale" + ssh_interface = "public_ip" + + launch_block_device_mappings { + delete_on_vm_deletion = false + device_name = "/dev/sda1" + volume_size = 40 + volume_type = "gp2" + } + launch_block_device_mappings { + device_name = "/dev/sdc" + volume_size = 50 + volume_type = "gp2" + } + launch_block_device_mappings { + device_name = "/dev/sdc" + volume_size = 100 + volume_type = "gp2" + } +} + +``` +##### with `omi_block_device_mappings` +```hcl +// export osc_access_key=$YOURKEY +variable "aws_access_key" { + type = string + // default = "hardcoded_key" +} + +// export osc_secret_key=$YOURSECRETKEY +variable "aws_secret_key" { + type = string + // default = "hardcoded_secret_key" +} + +source "outscale-bsu" "basic-example" { + region = "us-east-1" + vm_type = "t2.micro" + source_omi = "ami-abcfd0283" + omi_name = "packer_osc_{{timestamp}}" + root_device_name = "/dev/sda1" + ssh_username = "outscale" + ssh_interface = "public_ip" + + omi_block_device_mappings { + delete_on_vm_deletion = false + device_name = "/dev/sda1" + snapshot_id = "snap-792fce69" + volume_size = 40 + volume_type = "gp2" + } + omi_block_device_mappings { + device_name = "/dev/sdc" + snapshot_id = "snap-792fce69" + volume_size = 50 + volume_type = "gp2" + } +} + +``` + ```json { "type": "outscale-bsu", @@ -311,14 +415,16 @@ configuration of `launch_block_device_mappings` will expand the root volume "delete_on_vm_deletion": true } ], - "omi_block_device_mappings": [ + "launch_block_device_mappings": [ { "device_name": "/dev/sdb", - "virtual_name": "ephemeral0" + "volume_size": 50, + "volume_type": "gp2" }, { "device_name": "/dev/sdc", - "virtual_name": "ephemeral1" + "volume_size": 100, + "volume_type": "gp2" } ] } diff --git a/.web-docs/components/builder/bsusurrogate/README.md b/.web-docs/components/builder/bsusurrogate/README.md index 7f29bec..199dddb 100644 --- a/.web-docs/components/builder/bsusurrogate/README.md +++ b/.web-docs/components/builder/bsusurrogate/README.md @@ -62,8 +62,6 @@ builder. - `snapshot_id` (string) - The ID of the snapshot - - `virtual_name` (string) - The virtual device name. See the documentation on [Block Device Mapping](https://docs.outscale.com/en/userguide/Defining-Block-Device-Mappings.html) for more information. - - `volume_size` (number) - The size of the volume, in GiB. Required if not specifying a `snapshot_id` - `volume_type` (string) - The volume type. `gp2` for General Purpose (SSD) volumes, `io1` for Provisioned IOPS (SSD) volumes, and `standard` for Magnetic volumes @@ -182,18 +180,31 @@ builder. Example: - ```json - { - "source_omi_filter": { - "filters": { - "virtualization-type": "hvm", - "image-name": "image-name", - "root-device-type": "ebs" - }, - "owners": ["099720109477"] - } - } - ``` +#### HCL +```hcl +source_omi_filter { + filters = { + image-name = "image-name" + root-device-type = "ebs" + virtualization-type = "hvm" + } + owners = ["099720109477"] +} +``` + +#### JSON +```json +{ + "source_omi_filter": { + "filters": { + "virtualization-type": "hvm", + "image-name": "image-name", + "root-device-type": "ebs" + }, + "owners": ["099720109477"] + } +} +``` This selects an Ubuntu 16.04 HVM BSU OMIS from Canonical. NOTE: This will fail unless _exactly_ one OMIS is returned. In the above example, @@ -245,6 +256,52 @@ builder. ## Basic Example +#### HCL +```hcl +// export osc_access_key=$YOURKEY +variable "osc_access_key" { + type = string + // default = "hardcoded_key" +} + +// export osc_secret_key=$YOURSECRETKEY +variable "osc_secret_key" { + type = string + // default = "hardcoded_secret_key" +} + +source "outscale-bsusurrogate" "example-bsusurrogate" { + launch_block_device_mappings { + delete_on_vm_deletion = true + device_name = "/dev/xvdf" + iops = 3000 + volume_size = 200 + volume_type = "io1" + } + source_omi_filter { + filters = { + image-name = "image-name" + root-device-type = "ebs" + virtualization-type = "hvm" + } + owners = ["099720109477"] + } + omi_root_device { + delete_on_vm_deletion = true + device_name = "/dev/sda1" + source_device_name = "/dev/xvdf" + volume_size = 50 + volume_type = "standard" + } + omi_name = "packer_osc_{{timestamp}}" + source_omi = "ami-bcfc34e0" + ssh_interface = "public_ip" + ssh_username = "outscale" + vm_type = "t2.medium" + region = "eu-west-2" +} +``` +#### JSON ```json { "type": "outscale-bsusurrogate", diff --git a/builder/bsu/builder.hcl2spec.go b/builder/bsu/builder.hcl2spec.go index f6dd6fa..ffc99a2 100644 --- a/builder/bsu/builder.hcl2spec.go +++ b/builder/bsu/builder.hcl2spec.go @@ -44,6 +44,7 @@ type FlatConfig struct { SnapshotAccountIDs []string `mapstructure:"snapshot_account_ids" cty:"snapshot_account_ids" hcl:"snapshot_account_ids"` GlobalPermission *bool `mapstructure:"global_permission" cty:"global_permission" hcl:"global_permission"` ProductCodes []string `mapstructure:"product_codes" cty:"product_codes" hcl:"product_codes"` + RootDeviceName *string `mapstructure:"root_device_name" cty:"root_device_name" hcl:"root_device_name"` OMIMappings []common.FlatBlockDevice `mapstructure:"omi_block_device_mappings" cty:"omi_block_device_mappings" hcl:"omi_block_device_mappings"` LaunchMappings []common.FlatBlockDevice `mapstructure:"launch_block_device_mappings" cty:"launch_block_device_mappings" hcl:"launch_block_device_mappings"` AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" cty:"associate_public_ip_address" hcl:"associate_public_ip_address"` @@ -121,7 +122,6 @@ type FlatConfig struct { SSHInterface *string `mapstructure:"ssh_interface" cty:"ssh_interface" hcl:"ssh_interface"` VolumeRunTags common.TagMap `mapstructure:"run_volume_tags" cty:"run_volume_tags" hcl:"run_volume_tags"` SkipCreateOmi *bool `mapstructure:"skip_create_omi" cty:"skip_create_omi" hcl:"skip_create_omi"` - RootDeviceName *string `mapstructure:"" cty:"root_device_name" hcl:"root_device_name"` } // FlatMapstructure returns a new FlatConfig. @@ -169,6 +169,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "snapshot_account_ids": &hcldec.AttrSpec{Name: "snapshot_account_ids", Type: cty.List(cty.String), Required: false}, "global_permission": &hcldec.AttrSpec{Name: "global_permission", Type: cty.Bool, Required: false}, "product_codes": &hcldec.AttrSpec{Name: "product_codes", Type: cty.List(cty.String), Required: false}, + "root_device_name": &hcldec.AttrSpec{Name: "root_device_name", Type: cty.String, Required: false}, "omi_block_device_mappings": &hcldec.BlockListSpec{TypeName: "omi_block_device_mappings", Nested: hcldec.ObjectSpec((*common.FlatBlockDevice)(nil).HCL2Spec())}, "launch_block_device_mappings": &hcldec.BlockListSpec{TypeName: "launch_block_device_mappings", Nested: hcldec.ObjectSpec((*common.FlatBlockDevice)(nil).HCL2Spec())}, "associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false}, @@ -246,7 +247,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "ssh_interface": &hcldec.AttrSpec{Name: "ssh_interface", Type: cty.String, Required: false}, "run_volume_tags": &hcldec.AttrSpec{Name: "run_volume_tags", Type: cty.Map(cty.String), Required: false}, "skip_create_omi": &hcldec.AttrSpec{Name: "skip_create_omi", Type: cty.Bool, Required: false}, - "root_device_name": &hcldec.AttrSpec{Name: "root_device_name", Type: cty.String, Required: false}, } return s } diff --git a/builder/bsusurrogate/builder.hcl2spec.go b/builder/bsusurrogate/builder.hcl2spec.go index e8d36c7..826e000 100644 --- a/builder/bsusurrogate/builder.hcl2spec.go +++ b/builder/bsusurrogate/builder.hcl2spec.go @@ -119,6 +119,7 @@ type FlatConfig struct { SnapshotAccountIDs []string `mapstructure:"snapshot_account_ids" cty:"snapshot_account_ids" hcl:"snapshot_account_ids"` GlobalPermission *bool `mapstructure:"global_permission" cty:"global_permission" hcl:"global_permission"` ProductCodes []string `mapstructure:"product_codes" cty:"product_codes" hcl:"product_codes"` + RootDeviceName *string `mapstructure:"root_device_name" cty:"root_device_name" hcl:"root_device_name"` RootDevice *FlatRootBlockDevice `mapstructure:"omi_root_device" cty:"omi_root_device" hcl:"omi_root_device"` VolumeRunTags common.TagMap `mapstructure:"run_volume_tags" cty:"run_volume_tags" hcl:"run_volume_tags"` } @@ -243,6 +244,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "snapshot_account_ids": &hcldec.AttrSpec{Name: "snapshot_account_ids", Type: cty.List(cty.String), Required: false}, "global_permission": &hcldec.AttrSpec{Name: "global_permission", Type: cty.Bool, Required: false}, "product_codes": &hcldec.AttrSpec{Name: "product_codes", Type: cty.List(cty.String), Required: false}, + "root_device_name": &hcldec.AttrSpec{Name: "root_device_name", Type: cty.String, Required: false}, "omi_root_device": &hcldec.BlockSpec{TypeName: "omi_root_device", Nested: hcldec.ObjectSpec((*FlatRootBlockDevice)(nil).HCL2Spec())}, "run_volume_tags": &hcldec.AttrSpec{Name: "run_volume_tags", Type: cty.Map(cty.String), Required: false}, } diff --git a/builder/chroot/builder.go b/builder/chroot/builder.go index 271a5ec..ba3956a 100644 --- a/builder/chroot/builder.go +++ b/builder/chroot/builder.go @@ -43,7 +43,6 @@ type Config struct { MountPath string `mapstructure:"mount_path"` PostMountCommands []string `mapstructure:"post_mount_commands"` PreMountCommands []string `mapstructure:"pre_mount_commands"` - RootDeviceName string `mapstructure:"root_device_name"` RootVolumeSize int64 `mapstructure:"root_volume_size"` RootVolumeType string `mapstructure:"root_volume_type"` SourceOMI string `mapstructure:"source_omi"` diff --git a/builder/chroot/builder.hcl2spec.go b/builder/chroot/builder.hcl2spec.go index 8c7a0fb..c22be80 100644 --- a/builder/chroot/builder.hcl2spec.go +++ b/builder/chroot/builder.hcl2spec.go @@ -34,6 +34,7 @@ type FlatConfig struct { SnapshotAccountIDs []string `mapstructure:"snapshot_account_ids" cty:"snapshot_account_ids" hcl:"snapshot_account_ids"` GlobalPermission *bool `mapstructure:"global_permission" cty:"global_permission" hcl:"global_permission"` ProductCodes []string `mapstructure:"product_codes" cty:"product_codes" hcl:"product_codes"` + RootDeviceName *string `mapstructure:"root_device_name" cty:"root_device_name" hcl:"root_device_name"` AccessKey *string `mapstructure:"access_key" cty:"access_key" hcl:"access_key"` CustomEndpointOAPI *string `mapstructure:"custom_endpoint_oapi" cty:"custom_endpoint_oapi" hcl:"custom_endpoint_oapi"` InsecureSkipTLSVerify *bool `mapstructure:"insecure_skip_tls_verify" cty:"insecure_skip_tls_verify" hcl:"insecure_skip_tls_verify"` @@ -56,7 +57,6 @@ type FlatConfig struct { MountPath *string `mapstructure:"mount_path" cty:"mount_path" hcl:"mount_path"` PostMountCommands []string `mapstructure:"post_mount_commands" cty:"post_mount_commands" hcl:"post_mount_commands"` PreMountCommands []string `mapstructure:"pre_mount_commands" cty:"pre_mount_commands" hcl:"pre_mount_commands"` - RootDeviceName *string `mapstructure:"root_device_name" cty:"root_device_name" hcl:"root_device_name"` RootVolumeSize *int64 `mapstructure:"root_volume_size" cty:"root_volume_size" hcl:"root_volume_size"` RootVolumeType *string `mapstructure:"root_volume_type" cty:"root_volume_type" hcl:"root_volume_type"` SourceOMI *string `mapstructure:"source_omi" cty:"source_omi" hcl:"source_omi"` @@ -99,6 +99,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "snapshot_account_ids": &hcldec.AttrSpec{Name: "snapshot_account_ids", Type: cty.List(cty.String), Required: false}, "global_permission": &hcldec.AttrSpec{Name: "global_permission", Type: cty.Bool, Required: false}, "product_codes": &hcldec.AttrSpec{Name: "product_codes", Type: cty.List(cty.String), Required: false}, + "root_device_name": &hcldec.AttrSpec{Name: "root_device_name", Type: cty.String, Required: false}, "access_key": &hcldec.AttrSpec{Name: "access_key", Type: cty.String, Required: false}, "custom_endpoint_oapi": &hcldec.AttrSpec{Name: "custom_endpoint_oapi", Type: cty.String, Required: false}, "insecure_skip_tls_verify": &hcldec.AttrSpec{Name: "insecure_skip_tls_verify", Type: cty.Bool, Required: false}, @@ -121,7 +122,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "mount_path": &hcldec.AttrSpec{Name: "mount_path", Type: cty.String, Required: false}, "post_mount_commands": &hcldec.AttrSpec{Name: "post_mount_commands", Type: cty.List(cty.String), Required: false}, "pre_mount_commands": &hcldec.AttrSpec{Name: "pre_mount_commands", Type: cty.List(cty.String), Required: false}, - "root_device_name": &hcldec.AttrSpec{Name: "root_device_name", Type: cty.String, Required: false}, "root_volume_size": &hcldec.AttrSpec{Name: "root_volume_size", Type: cty.Number, Required: false}, "root_volume_type": &hcldec.AttrSpec{Name: "root_volume_type", Type: cty.String, Required: false}, "source_omi": &hcldec.AttrSpec{Name: "source_omi", Type: cty.String, Required: false}, diff --git a/docs/builders/bsu.mdx b/docs/builders/bsu.mdx index 875694b..9c9eeeb 100644 --- a/docs/builders/bsu.mdx +++ b/docs/builders/bsu.mdx @@ -76,8 +76,6 @@ builder. - `snapshot_id` (string) - The ID of the snapshot - - `virtual_name` (string) - The virtual device name. See the documentation on [Block Device Mapping](https://docs.outscale.com/en/userguide/Defining-Block-Device-Mappings.html) for more information - - `volume_size` (number) - The size of the volume, in GiB. Required if not specifying a `snapshot_id` - `volume_type` (string) - The volume type. `gp2` for General Purpose (SSD) volumes, `io1` for Provisioned IOPS (SSD) volumes, and `standard` for Magnetic volumes @@ -181,7 +179,19 @@ builder. - `owners` (array of strings) - Filters the images by their owner. You may specify one or more Outscale account IDs, "self" (which will use the account whose credentials you are using to run Packer). This option is required for security reasons. Example: + #### HCL + ```hcl + source_omi_filter { + filters = { + image-name = "image-name-in-account" + root-device-type = "ebs" # or "bsu" + virtualization-type = "hvm" + } + owners = ["339215505907"] + } + ``` + #### JSON ```json { "source_omi_filter": { @@ -248,7 +258,19 @@ builder. ## Basic Example Here is a basic example. You will need to provide access keys, and may need to change the OMIS IDs according to what images exist at the time the template is run: +#### HCL +```hcl +source "outscale-bsu" "basic-example" { + region = "us-east-1" + vm_type = "t2.micro" + source_omi = "ami-abcfd0283" + omi_name = "packer_osc_{{timestamp}}" + ssh_username = "outscale" + ssh_interface = "public_ip" +} +``` +#### JSON ```json { "variables": { @@ -288,9 +310,91 @@ You can use this information to access the VM as it is running. Here is an example using the optional OMIS block device mappings. Our configuration of `launch_block_device_mappings` will expand the root volume (`/dev/sda`) to 40gb during the build (up from the default of 8gb). With -`ami_block_device_mappings` Outscale will attach additional volumes `/dev/sdb` and +`omi_block_device_mappings` Outscale will attach additional volumes `/dev/sdb` and `/dev/sdc` when we boot a new VM of our OMI. +#### HCL +##### with `launch_block_device_mappings` +```hcl +// export osc_access_key=$YOURKEY +variable "osc_access_key" { + type = string + // default = "hardcoded_key" +} + +// export osc_secret_key=$YOURSECRETKEY +variable "osc_secret_key" { + type = string + // default = "hardcoded_secret_key" +} + +source "outscale-bsu" "basic-example" { + region = "us-east-1" + vm_type = "t2.micro" + source_omi = "ami-abcfd0283" + omi_name = "packer_osc_{{timestamp}}" + ssh_username = "outscale" + ssh_interface = "public_ip" + + launch_block_device_mappings { + delete_on_vm_deletion = false + device_name = "/dev/sda1" + volume_size = 40 + volume_type = "gp2" + } + launch_block_device_mappings { + device_name = "/dev/sdc" + volume_size = 50 + volume_type = "gp2" + } + launch_block_device_mappings { + device_name = "/dev/sdc" + volume_size = 100 + volume_type = "gp2" + } +} + +``` +##### with `omi_block_device_mappings` +```hcl +// export osc_access_key=$YOURKEY +variable "aws_access_key" { + type = string + // default = "hardcoded_key" +} + +// export osc_secret_key=$YOURSECRETKEY +variable "aws_secret_key" { + type = string + // default = "hardcoded_secret_key" +} + +source "outscale-bsu" "basic-example" { + region = "us-east-1" + vm_type = "t2.micro" + source_omi = "ami-abcfd0283" + omi_name = "packer_osc_{{timestamp}}" + root_device_name = "/dev/sda1" + ssh_username = "outscale" + ssh_interface = "public_ip" + + omi_block_device_mappings { + delete_on_vm_deletion = false + device_name = "/dev/sda1" + snapshot_id = "snap-792fce69" + volume_size = 40 + volume_type = "gp2" + } + omi_block_device_mappings { + device_name = "/dev/sdc" + snapshot_id = "snap-792fce69" + volume_size = 50 + volume_type = "gp2" + } +} + +``` + ```json { "type": "outscale-bsu", @@ -309,14 +413,16 @@ configuration of `launch_block_device_mappings` will expand the root volume "delete_on_vm_deletion": true } ], - "omi_block_device_mappings": [ + "launch_block_device_mappings": [ { "device_name": "/dev/sdb", - "virtual_name": "ephemeral0" + "volume_size": 50, + "volume_type": "gp2" }, { "device_name": "/dev/sdc", - "virtual_name": "ephemeral1" + "volume_size": 100, + "volume_type": "gp2" } ] } diff --git a/docs/builders/bsusurrogate.mdx b/docs/builders/bsusurrogate.mdx index 58e1df9..3cc1617 100644 --- a/docs/builders/bsusurrogate.mdx +++ b/docs/builders/bsusurrogate.mdx @@ -72,8 +72,6 @@ builder. - `snapshot_id` (string) - The ID of the snapshot - - `virtual_name` (string) - The virtual device name. See the documentation on [Block Device Mapping](https://docs.outscale.com/en/userguide/Defining-Block-Device-Mappings.html) for more information. - - `volume_size` (number) - The size of the volume, in GiB. Required if not specifying a `snapshot_id` - `volume_type` (string) - The volume type. `gp2` for General Purpose (SSD) volumes, `io1` for Provisioned IOPS (SSD) volumes, and `standard` for Magnetic volumes @@ -192,18 +190,31 @@ builder. Example: - ```json - { - "source_omi_filter": { - "filters": { - "virtualization-type": "hvm", - "image-name": "image-name", - "root-device-type": "ebs" - }, - "owners": ["099720109477"] - } - } - ``` +#### HCL +```hcl +source_omi_filter { + filters = { + image-name = "image-name" + root-device-type = "ebs" + virtualization-type = "hvm" + } + owners = ["099720109477"] +} +``` + +#### JSON +```json +{ + "source_omi_filter": { + "filters": { + "virtualization-type": "hvm", + "image-name": "image-name", + "root-device-type": "ebs" + }, + "owners": ["099720109477"] + } +} +``` This selects an Ubuntu 16.04 HVM BSU OMIS from Canonical. NOTE: This will fail unless _exactly_ one OMIS is returned. In the above example, @@ -255,6 +266,52 @@ builder. ## Basic Example +#### HCL +```hcl +// export osc_access_key=$YOURKEY +variable "osc_access_key" { + type = string + // default = "hardcoded_key" +} + +// export osc_secret_key=$YOURSECRETKEY +variable "osc_secret_key" { + type = string + // default = "hardcoded_secret_key" +} + +source "outscale-bsusurrogate" "example-bsusurrogate" { + launch_block_device_mappings { + delete_on_vm_deletion = true + device_name = "/dev/xvdf" + iops = 3000 + volume_size = 200 + volume_type = "io1" + } + source_omi_filter { + filters = { + image-name = "image-name" + root-device-type = "ebs" + virtualization-type = "hvm" + } + owners = ["099720109477"] + } + omi_root_device { + delete_on_vm_deletion = true + device_name = "/dev/sda1" + source_device_name = "/dev/xvdf" + volume_size = 50 + volume_type = "standard" + } + omi_name = "packer_osc_{{timestamp}}" + source_omi = "ami-bcfc34e0" + ssh_interface = "public_ip" + ssh_username = "outscale" + vm_type = "t2.medium" + region = "eu-west-2" +} +``` +#### JSON ```json { "type": "outscale-bsusurrogate",