Revert "provider/alicloud: change create ecs postpaid instance API" (#12724)
* Revert "datadog: Fix incorrect schema of monitor for 'silenced' (#12720)" This reverts commit8730bf125f
. * Revert "schema: Allow *Resource as Elem of TypeMap in validation (#12722)" This reverts commit1df1c21d5b
. * Revert "provider/alicloud: change create ecs postpaid instance API (#12226)" This reverts commitffc5a06cb5
.
This commit is contained in:
parent
8730bf125f
commit
408ce5fe3f
|
@ -2,7 +2,6 @@ package alicloud
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/denverdino/aliyungo/common"
|
"github.com/denverdino/aliyungo/common"
|
||||||
"github.com/denverdino/aliyungo/ecs"
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -51,10 +50,3 @@ func isProtocalValid(value string) bool {
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultBusinessInfo = ecs.BusinessInfo{
|
|
||||||
Pack: "terraform",
|
|
||||||
}
|
|
||||||
|
|
||||||
// default region for all resource
|
|
||||||
const DEFAULT_REGION = "cn-beijing"
|
|
||||||
|
|
|
@ -19,10 +19,8 @@ type Config struct {
|
||||||
type AliyunClient struct {
|
type AliyunClient struct {
|
||||||
Region common.Region
|
Region common.Region
|
||||||
ecsconn *ecs.Client
|
ecsconn *ecs.Client
|
||||||
// use new version
|
vpcconn *ecs.Client
|
||||||
ecsNewconn *ecs.Client
|
slbconn *slb.Client
|
||||||
vpcconn *ecs.Client
|
|
||||||
slbconn *slb.Client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client for AliyunClient
|
// Client for AliyunClient
|
||||||
|
@ -37,12 +35,6 @@ func (c *Config) Client() (*AliyunClient, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ecsNewconn, err := c.ecsConn()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ecsNewconn.SetVersion(EcsApiVersion20160314)
|
|
||||||
|
|
||||||
slbconn, err := c.slbConn()
|
slbconn, err := c.slbConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -54,27 +46,13 @@ func (c *Config) Client() (*AliyunClient, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &AliyunClient{
|
return &AliyunClient{
|
||||||
Region: c.Region,
|
Region: c.Region,
|
||||||
ecsconn: ecsconn,
|
ecsconn: ecsconn,
|
||||||
ecsNewconn: ecsNewconn,
|
vpcconn: vpcconn,
|
||||||
vpcconn: vpcconn,
|
slbconn: slbconn,
|
||||||
slbconn: slbconn,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// return new ecs Client
|
|
||||||
// when you need new client not global client, use this method
|
|
||||||
func (c *Config) NewEcsConn() (*ecs.Client, error) {
|
|
||||||
client := ecs.NewClient(c.AccessKey, c.SecretKey)
|
|
||||||
_, err := client.DescribeRegions()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return client, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Config) loadAndValidate() error {
|
func (c *Config) loadAndValidate() error {
|
||||||
err := c.validateRegion()
|
err := c.validateRegion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/denverdino/aliyungo/ecs"
|
"github.com/denverdino/aliyungo/ecs"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAlicloudImages() *schema.Resource {
|
func dataSourceAlicloudImages() *schema.Resource {
|
||||||
|
@ -175,28 +175,15 @@ func dataSourceAlicloudImagesRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
params.ImageOwnerAlias = ecs.ImageOwnerAlias(owners.(string))
|
params.ImageOwnerAlias = ecs.ImageOwnerAlias(owners.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
var allImages []ecs.ImageType
|
resp, _, err := conn.DescribeImages(params)
|
||||||
|
if err != nil {
|
||||||
for {
|
return err
|
||||||
images, paginationResult, err := conn.DescribeImages(params)
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
allImages = append(allImages, images...)
|
|
||||||
|
|
||||||
pagination := paginationResult.NextPage()
|
|
||||||
if pagination == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
params.Pagination = *pagination
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var filteredImages []ecs.ImageType
|
var filteredImages []ecs.ImageType
|
||||||
if nameRegexOk {
|
if nameRegexOk {
|
||||||
r := regexp.MustCompile(nameRegex.(string))
|
r := regexp.MustCompile(nameRegex.(string))
|
||||||
for _, image := range allImages {
|
for _, image := range resp {
|
||||||
// Check for a very rare case where the response would include no
|
// Check for a very rare case where the response would include no
|
||||||
// image name. No name means nothing to attempt a match against,
|
// image name. No name means nothing to attempt a match against,
|
||||||
// therefore we are skipping such image.
|
// therefore we are skipping such image.
|
||||||
|
@ -211,7 +198,7 @@ func dataSourceAlicloudImagesRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filteredImages = allImages[:]
|
filteredImages = resp[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
var images []ecs.ImageType
|
var images []ecs.ImageType
|
||||||
|
|
|
@ -97,22 +97,6 @@ func TestAccAlicloudImagesDataSource_nameRegexFilter(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAlicloudImagesDataSource_imageNotInFirstPage(t *testing.T) {
|
|
||||||
resource.Test(t, resource.TestCase{
|
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
|
||||||
Providers: testAccProviders,
|
|
||||||
Steps: []resource.TestStep{
|
|
||||||
{
|
|
||||||
Config: testAccCheckAlicloudImagesDataSourceImageNotInFirstPageConfig,
|
|
||||||
Check: resource.ComposeTestCheckFunc(
|
|
||||||
testAccCheckAlicloudDataSourceID("data.alicloud_images.name_regex_filtered_image"),
|
|
||||||
resource.TestMatchResourceAttr("data.alicloud_images.name_regex_filtered_image", "images.0.image_id", regexp.MustCompile("^ubuntu_1404")),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instance store test - using centos images
|
// Instance store test - using centos images
|
||||||
const testAccCheckAlicloudImagesDataSourceImagesConfig = `
|
const testAccCheckAlicloudImagesDataSourceImagesConfig = `
|
||||||
data "alicloud_images" "multi_image" {
|
data "alicloud_images" "multi_image" {
|
||||||
|
@ -144,12 +128,3 @@ data "alicloud_images" "name_regex_filtered_image" {
|
||||||
name_regex = "^centos_6\\w{1,5}[64]{1}.*"
|
name_regex = "^centos_6\\w{1,5}[64]{1}.*"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
// Testing image not in first page response
|
|
||||||
const testAccCheckAlicloudImagesDataSourceImageNotInFirstPageConfig = `
|
|
||||||
data "alicloud_images" "name_regex_filtered_image" {
|
|
||||||
most_recent = true
|
|
||||||
owners = "system"
|
|
||||||
name_regex = "^ubuntu_1404\\d{2}_64"
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ func TestAccAlicloudInstanceTypesDataSource_basic(t *testing.T) {
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAlicloudDataSourceID("data.alicloud_instance_types.4c8g"),
|
testAccCheckAlicloudDataSourceID("data.alicloud_instance_types.4c8g"),
|
||||||
|
|
||||||
|
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.#", "4"),
|
||||||
|
|
||||||
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.0.cpu_core_count", "4"),
|
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.0.cpu_core_count", "4"),
|
||||||
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.0.memory_size", "8"),
|
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.0.memory_size", "8"),
|
||||||
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.0.id", "ecs.s3.large"),
|
resource.TestCheckResourceAttr("data.alicloud_instance_types.4c8g", "instance_types.0.id", "ecs.s3.large"),
|
||||||
|
|
|
@ -71,6 +71,9 @@ func TestAccAlicloudRegionsDataSource_empty(t *testing.T) {
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAlicloudDataSourceID("data.alicloud_regions.empty_params_region"),
|
testAccCheckAlicloudDataSourceID("data.alicloud_regions.empty_params_region"),
|
||||||
|
|
||||||
|
resource.TestCheckResourceAttr("data.alicloud_regions.empty_params_region", "name", ""),
|
||||||
|
resource.TestCheckResourceAttr("data.alicloud_regions.empty_params_region", "current", ""),
|
||||||
|
|
||||||
resource.TestCheckResourceAttr("data.alicloud_regions.empty_params_region", "regions.#", "13"),
|
resource.TestCheckResourceAttr("data.alicloud_regions.empty_params_region", "regions.#", "13"),
|
||||||
|
|
||||||
resource.TestCheckResourceAttr("data.alicloud_regions.empty_params_region", "regions.0.id", "cn-shenzhen"),
|
resource.TestCheckResourceAttr("data.alicloud_regions.empty_params_region", "regions.0.id", "cn-shenzhen"),
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package alicloud
|
package alicloud
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
|
||||||
"strconv"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,35 +23,6 @@ func TestAccAlicloudZonesDataSource_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAlicloudZonesDataSource_filter(t *testing.T) {
|
func TestAccAlicloudZonesDataSource_filter(t *testing.T) {
|
||||||
// the zone length changed occasionally
|
|
||||||
// check by range to avoid test case failure
|
|
||||||
testCheckZoneLength := func(name string) resource.TestCheckFunc {
|
|
||||||
return func(s *terraform.State) error {
|
|
||||||
ms := s.RootModule()
|
|
||||||
rs, ok := ms.Resources[name]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("Not found: %s", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
is := rs.Primary
|
|
||||||
if is == nil {
|
|
||||||
return fmt.Errorf("No primary instance: %s", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
i, err := strconv.Atoi(is.Attributes["zones.#"])
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("convert zone length err: %#v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if i <= 0 {
|
|
||||||
return fmt.Errorf("zone length expected greater than 0 got err: %d", i)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() {
|
PreCheck: func() {
|
||||||
testAccPreCheck(t)
|
testAccPreCheck(t)
|
||||||
|
@ -65,7 +33,7 @@ func TestAccAlicloudZonesDataSource_filter(t *testing.T) {
|
||||||
Config: testAccCheckAlicloudZonesDataSourceFilter,
|
Config: testAccCheckAlicloudZonesDataSourceFilter,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAlicloudDataSourceID("data.alicloud_zones.foo"),
|
testAccCheckAlicloudDataSourceID("data.alicloud_zones.foo"),
|
||||||
testCheckZoneLength("data.alicloud_zones.foo"),
|
resource.TestCheckResourceAttr("data.alicloud_zones.foo", "zones.#", "2"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -73,7 +41,7 @@ func TestAccAlicloudZonesDataSource_filter(t *testing.T) {
|
||||||
Config: testAccCheckAlicloudZonesDataSourceFilterIoOptimized,
|
Config: testAccCheckAlicloudZonesDataSourceFilterIoOptimized,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAlicloudDataSourceID("data.alicloud_zones.foo"),
|
testAccCheckAlicloudDataSourceID("data.alicloud_zones.foo"),
|
||||||
testCheckZoneLength("data.alicloud_zones.foo"),
|
resource.TestCheckResourceAttr("data.alicloud_zones.foo", "zones.#", "1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,8 +30,3 @@ const (
|
||||||
GroupRulePolicyAccept = GroupRulePolicy("accept")
|
GroupRulePolicyAccept = GroupRulePolicy("accept")
|
||||||
GroupRulePolicyDrop = GroupRulePolicy("drop")
|
GroupRulePolicyDrop = GroupRulePolicy("drop")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
EcsApiVersion20160314 = "2016-03-14"
|
|
||||||
EcsApiVersion20140526 = "2014-05-26"
|
|
||||||
)
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ func Provider() terraform.ResourceProvider {
|
||||||
"region": &schema.Schema{
|
"region": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("ALICLOUD_REGION", DEFAULT_REGION),
|
DefaultFunc: schema.EnvDefaultFunc("ALICLOUD_REGION", "cn-beijing"),
|
||||||
Description: descriptions["region"],
|
Description: descriptions["region"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -136,13 +136,9 @@ func testAccCheckDiskDestroy(s *terraform.State) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccDiskConfig = `
|
const testAccDiskConfig = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_disk" "foo" {
|
resource "alicloud_disk" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
name = "New-disk"
|
name = "New-disk"
|
||||||
description = "Hello ecs disk."
|
description = "Hello ecs disk."
|
||||||
category = "cloud_efficiency"
|
category = "cloud_efficiency"
|
||||||
|
@ -150,15 +146,10 @@ resource "alicloud_disk" "foo" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const testAccDiskConfigWithTags = `
|
const testAccDiskConfigWithTags = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_disk" "bar" {
|
resource "alicloud_disk" "bar" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
category = "cloud_efficiency"
|
size = "10"
|
||||||
size = "20"
|
|
||||||
tags {
|
tags {
|
||||||
Name = "TerraformTest"
|
Name = "TerraformTest"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
|
||||||
"github.com/denverdino/aliyungo/common"
|
"github.com/denverdino/aliyungo/common"
|
||||||
"github.com/denverdino/aliyungo/ecs"
|
"github.com/denverdino/aliyungo/ecs"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
@ -22,9 +21,8 @@ func resourceAliyunInstance() *schema.Resource {
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"availability_zone": &schema.Schema{
|
"availability_zone": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Computed: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"image_id": &schema.Schema{
|
"image_id": &schema.Schema{
|
||||||
|
@ -63,11 +61,8 @@ func resourceAliyunInstance() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"instance_network_type": &schema.Schema{
|
"instance_network_type": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Computed: true,
|
||||||
ForceNew: true,
|
|
||||||
Computed: true,
|
|
||||||
ValidateFunc: validateInstanceNetworkType,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"internet_charge_type": &schema.Schema{
|
"internet_charge_type": &schema.Schema{
|
||||||
|
@ -150,6 +145,7 @@ func resourceAliyunInstance() *schema.Resource {
|
||||||
|
|
||||||
"private_ip": &schema.Schema{
|
"private_ip": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -172,11 +168,6 @@ func resourceAliyunInstance() *schema.Resource {
|
||||||
func resourceAliyunInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAliyunInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AliyunClient).ecsconn
|
conn := meta.(*AliyunClient).ecsconn
|
||||||
|
|
||||||
// create postpaid instance by runInstances API
|
|
||||||
if v := d.Get("instance_charge_type").(string); v != string(common.PrePaid) {
|
|
||||||
return resourceAliyunRunInstance(d, meta)
|
|
||||||
}
|
|
||||||
|
|
||||||
args, err := buildAliyunInstanceArgs(d, meta)
|
args, err := buildAliyunInstanceArgs(d, meta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -216,49 +207,6 @@ func resourceAliyunInstanceCreate(d *schema.ResourceData, meta interface{}) erro
|
||||||
return resourceAliyunInstanceUpdate(d, meta)
|
return resourceAliyunInstanceUpdate(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAliyunRunInstance(d *schema.ResourceData, meta interface{}) error {
|
|
||||||
conn := meta.(*AliyunClient).ecsconn
|
|
||||||
newConn := meta.(*AliyunClient).ecsNewconn
|
|
||||||
|
|
||||||
args, err := buildAliyunInstanceArgs(d, meta)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
runArgs, err := buildAliyunRunInstancesArgs(d, meta)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
runArgs.CreateInstanceArgs = *args
|
|
||||||
|
|
||||||
// runInstances is support in version 2016-03-14
|
|
||||||
instanceIds, err := newConn.RunInstances(runArgs)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Error creating Aliyun ecs instance: %#v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId(instanceIds[0])
|
|
||||||
|
|
||||||
d.Set("password", d.Get("password"))
|
|
||||||
d.Set("system_disk_category", d.Get("system_disk_category"))
|
|
||||||
|
|
||||||
if d.Get("allocate_public_ip").(bool) {
|
|
||||||
_, err := conn.AllocatePublicIpAddress(d.Id())
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[DEBUG] AllocatePublicIpAddress for instance got error: %#v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// after instance created, its status change from pending, starting to running
|
|
||||||
if err := conn.WaitForInstanceAsyn(d.Id(), ecs.Running, defaultTimeout); err != nil {
|
|
||||||
log.Printf("[DEBUG] WaitForInstance %s got error: %#v", ecs.Running, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceAliyunInstanceUpdate(d, meta)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceAliyunInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAliyunInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*AliyunClient)
|
client := meta.(*AliyunClient)
|
||||||
conn := client.ecsconn
|
conn := client.ecsconn
|
||||||
|
@ -466,68 +414,33 @@ func resourceAliyunInstanceDelete(d *schema.ResourceData, meta interface{}) erro
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func buildAliyunRunInstancesArgs(d *schema.ResourceData, meta interface{}) (*ecs.RunInstanceArgs, error) {
|
|
||||||
args := &ecs.RunInstanceArgs{
|
|
||||||
MaxAmount: 1,
|
|
||||||
MinAmount: 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
bussStr, err := json.Marshal(DefaultBusinessInfo)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Failed to translate bussiness info %#v from json to string", DefaultBusinessInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
args.BusinessInfo = string(bussStr)
|
|
||||||
|
|
||||||
subnetValue := d.Get("subnet_id").(string)
|
|
||||||
vswitchValue := d.Get("vswitch_id").(string)
|
|
||||||
networkValue := d.Get("instance_network_type").(string)
|
|
||||||
|
|
||||||
// because runInstance is not compatible with createInstance, force NetworkType value to classic
|
|
||||||
if subnetValue == "" && vswitchValue == "" && networkValue == "" {
|
|
||||||
args.NetworkType = string(ClassicNet)
|
|
||||||
}
|
|
||||||
|
|
||||||
return args, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildAliyunInstanceArgs(d *schema.ResourceData, meta interface{}) (*ecs.CreateInstanceArgs, error) {
|
func buildAliyunInstanceArgs(d *schema.ResourceData, meta interface{}) (*ecs.CreateInstanceArgs, error) {
|
||||||
client := meta.(*AliyunClient)
|
client := meta.(*AliyunClient)
|
||||||
|
|
||||||
args := &ecs.CreateInstanceArgs{
|
args := &ecs.CreateInstanceArgs{
|
||||||
RegionId: getRegion(d, meta),
|
RegionId: getRegion(d, meta),
|
||||||
InstanceType: d.Get("instance_type").(string),
|
InstanceType: d.Get("instance_type").(string),
|
||||||
|
PrivateIpAddress: d.Get("private_ip").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
imageID := d.Get("image_id").(string)
|
imageID := d.Get("image_id").(string)
|
||||||
|
|
||||||
args.ImageId = imageID
|
args.ImageId = imageID
|
||||||
|
|
||||||
systemDiskCategory := ecs.DiskCategory(d.Get("system_disk_category").(string))
|
|
||||||
|
|
||||||
zoneID := d.Get("availability_zone").(string)
|
zoneID := d.Get("availability_zone").(string)
|
||||||
// check instanceType and systemDiskCategory, when zoneID is not empty
|
|
||||||
if zoneID != "" {
|
|
||||||
zone, err := client.DescribeZone(zoneID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := client.ResourceAvailable(zone, ecs.ResourceTypeInstance); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := client.DiskAvailable(zone, systemDiskCategory); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
args.ZoneId = zoneID
|
|
||||||
|
|
||||||
|
zone, err := client.DescribeZone(zoneID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
args.SystemDisk = ecs.SystemDiskType{
|
|
||||||
Category: systemDiskCategory,
|
if err := client.ResourceAvailable(zone, ecs.ResourceTypeInstance); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.ZoneId = zoneID
|
||||||
|
|
||||||
sgs, ok := d.GetOk("security_groups")
|
sgs, ok := d.GetOk("security_groups")
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -541,6 +454,16 @@ func buildAliyunInstanceArgs(d *schema.ResourceData, meta interface{}) (*ecs.Cre
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
systemDiskCategory := ecs.DiskCategory(d.Get("system_disk_category").(string))
|
||||||
|
|
||||||
|
if err := client.DiskAvailable(zone, systemDiskCategory); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
args.SystemDisk = ecs.SystemDiskType{
|
||||||
|
Category: systemDiskCategory,
|
||||||
|
}
|
||||||
|
|
||||||
if v := d.Get("instance_name").(string); v != "" {
|
if v := d.Get("instance_name").(string); v != "" {
|
||||||
args.InstanceName = v
|
args.InstanceName = v
|
||||||
}
|
}
|
||||||
|
@ -567,11 +490,7 @@ func buildAliyunInstanceArgs(d *schema.ResourceData, meta interface{}) (*ecs.Cre
|
||||||
}
|
}
|
||||||
|
|
||||||
if v := d.Get("io_optimized").(string); v != "" {
|
if v := d.Get("io_optimized").(string); v != "" {
|
||||||
if v == "optimized" {
|
args.IoOptimized = ecs.IoOptimized(v)
|
||||||
args.IoOptimized = ecs.IoOptimized("true")
|
|
||||||
} else {
|
|
||||||
args.IoOptimized = ecs.IoOptimized("false")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vswitchValue := d.Get("subnet_id").(string)
|
vswitchValue := d.Get("subnet_id").(string)
|
||||||
|
|
|
@ -355,6 +355,10 @@ func TestAccAlicloudInstance_tags(t *testing.T) {
|
||||||
Config: testAccCheckInstanceConfigTagsUpdate,
|
Config: testAccCheckInstanceConfigTagsUpdate,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckInstanceExists("alicloud_instance.foo", &instance),
|
testAccCheckInstanceExists("alicloud_instance.foo", &instance),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"alicloud_instance.foo",
|
||||||
|
"tags.foo",
|
||||||
|
""),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"alicloud_instance.foo",
|
"alicloud_instance.foo",
|
||||||
"tags.bar",
|
"tags.bar",
|
||||||
|
@ -414,8 +418,8 @@ func TestAccAlicloudInstance_privateIP(t *testing.T) {
|
||||||
testCheckPrivateIP := func() resource.TestCheckFunc {
|
testCheckPrivateIP := func() resource.TestCheckFunc {
|
||||||
return func(*terraform.State) error {
|
return func(*terraform.State) error {
|
||||||
privateIP := instance.VpcAttributes.PrivateIpAddress.IpAddress[0]
|
privateIP := instance.VpcAttributes.PrivateIpAddress.IpAddress[0]
|
||||||
if privateIP == "" {
|
if privateIP != "172.16.0.229" {
|
||||||
return fmt.Errorf("can't get private IP")
|
return fmt.Errorf("bad private IP: %s", privateIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -441,14 +445,14 @@ func TestAccAlicloudInstance_privateIP(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAlicloudInstance_associatePublicIP(t *testing.T) {
|
func TestAccAlicloudInstance_associatePublicIPAndPrivateIP(t *testing.T) {
|
||||||
var instance ecs.InstanceAttributesType
|
var instance ecs.InstanceAttributesType
|
||||||
|
|
||||||
testCheckPrivateIP := func() resource.TestCheckFunc {
|
testCheckPrivateIP := func() resource.TestCheckFunc {
|
||||||
return func(*terraform.State) error {
|
return func(*terraform.State) error {
|
||||||
privateIP := instance.VpcAttributes.PrivateIpAddress.IpAddress[0]
|
privateIP := instance.VpcAttributes.PrivateIpAddress.IpAddress[0]
|
||||||
if privateIP == "" {
|
if privateIP != "172.16.0.229" {
|
||||||
return fmt.Errorf("can't get private IP")
|
return fmt.Errorf("bad private IP: %s", privateIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -464,7 +468,7 @@ func TestAccAlicloudInstance_associatePublicIP(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckInstanceDestroy,
|
CheckDestroy: testAccCheckInstanceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccInstanceConfigAssociatePublicIP,
|
Config: testAccInstanceConfigAssociatePublicIPAndPrivateIP,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckInstanceExists("alicloud_instance.foo", &instance),
|
testAccCheckInstanceExists("alicloud_instance.foo", &instance),
|
||||||
testCheckPrivateIP(),
|
testCheckPrivateIP(),
|
||||||
|
@ -605,6 +609,8 @@ resource "alicloud_security_group" "tf_test_bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
system_disk_category = "cloud_ssd"
|
system_disk_category = "cloud_ssd"
|
||||||
|
@ -622,11 +628,6 @@ resource "alicloud_instance" "foo" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const testAccInstanceConfigVPC = `
|
const testAccInstanceConfigVPC = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -635,7 +636,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "tf_test_foo" {
|
resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
@ -646,6 +647,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
vswitch_id = "${alicloud_vswitch.foo.id}"
|
vswitch_id = "${alicloud_vswitch.foo.id}"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
|
@ -664,11 +666,6 @@ resource "alicloud_instance" "foo" {
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccInstanceConfigUserData = `
|
const testAccInstanceConfigUserData = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -677,7 +674,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "tf_test_foo" {
|
resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
@ -688,6 +685,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
vswitch_id = "${alicloud_vswitch.foo.id}"
|
vswitch_id = "${alicloud_vswitch.foo.id}"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
# series II
|
# series II
|
||||||
|
@ -729,6 +727,7 @@ resource "alicloud_security_group" "tf_test_bar" {
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
provider = "alicloud.beijing"
|
provider = "alicloud.beijing"
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
internet_charge_type = "PayByBandwidth"
|
internet_charge_type = "PayByBandwidth"
|
||||||
|
@ -743,6 +742,7 @@ resource "alicloud_instance" "foo" {
|
||||||
resource "alicloud_instance" "bar" {
|
resource "alicloud_instance" "bar" {
|
||||||
# cn-shanghai
|
# cn-shanghai
|
||||||
provider = "alicloud.shanghai"
|
provider = "alicloud.shanghai"
|
||||||
|
availability_zone = "cn-shanghai-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
internet_charge_type = "PayByBandwidth"
|
internet_charge_type = "PayByBandwidth"
|
||||||
|
@ -768,6 +768,7 @@ resource "alicloud_security_group" "tf_test_bar" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
instance_type = "ecs.s2.large"
|
instance_type = "ecs.s2.large"
|
||||||
|
@ -775,7 +776,6 @@ resource "alicloud_instance" "foo" {
|
||||||
security_groups = ["${alicloud_security_group.tf_test_foo.id}", "${alicloud_security_group.tf_test_bar.id}"]
|
security_groups = ["${alicloud_security_group.tf_test_foo.id}", "${alicloud_security_group.tf_test_bar.id}"]
|
||||||
instance_name = "test_foo"
|
instance_name = "test_foo"
|
||||||
io_optimized = "optimized"
|
io_optimized = "optimized"
|
||||||
system_disk_category = "cloud_efficiency"
|
|
||||||
}`
|
}`
|
||||||
|
|
||||||
const testAccInstanceConfig_multiSecurityGroup_add = `
|
const testAccInstanceConfig_multiSecurityGroup_add = `
|
||||||
|
@ -796,6 +796,7 @@ resource "alicloud_security_group" "tf_test_add_sg" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
instance_type = "ecs.s2.large"
|
instance_type = "ecs.s2.large"
|
||||||
|
@ -804,7 +805,6 @@ resource "alicloud_instance" "foo" {
|
||||||
"${alicloud_security_group.tf_test_add_sg.id}"]
|
"${alicloud_security_group.tf_test_add_sg.id}"]
|
||||||
instance_name = "test_foo"
|
instance_name = "test_foo"
|
||||||
io_optimized = "optimized"
|
io_optimized = "optimized"
|
||||||
system_disk_category = "cloud_efficiency"
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -816,6 +816,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
instance_type = "ecs.s2.large"
|
instance_type = "ecs.s2.large"
|
||||||
|
@ -823,7 +824,6 @@ resource "alicloud_instance" "foo" {
|
||||||
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
||||||
instance_name = "test_foo"
|
instance_name = "test_foo"
|
||||||
io_optimized = "optimized"
|
io_optimized = "optimized"
|
||||||
system_disk_category = "cloud_efficiency"
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -836,23 +836,18 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
instance_type = "ecs.s2.large"
|
instance_type = "ecs.s2.large"
|
||||||
internet_charge_type = "PayByBandwidth"
|
internet_charge_type = "PayByBandwidth"
|
||||||
security_groups = ["${alicloud_security_group.tf_test_foo.*.id}"]
|
security_groups = ["${alicloud_security_group.tf_test_foo.*.id}"]
|
||||||
instance_name = "test_foo"
|
instance_name = "test_foo"
|
||||||
io_optimized = "optimized"
|
io_optimized = "none"
|
||||||
system_disk_category = "cloud_efficiency"
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccInstanceNetworkInstanceSecurityGroups = `
|
const testAccInstanceNetworkInstanceSecurityGroups = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -861,7 +856,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "tf_test_foo" {
|
resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
@ -872,6 +867,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
vswitch_id = "${alicloud_vswitch.foo.id}"
|
vswitch_id = "${alicloud_vswitch.foo.id}"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
|
@ -896,6 +892,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
|
@ -921,6 +918,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
|
@ -945,6 +943,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
|
@ -968,6 +967,7 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
|
@ -984,11 +984,6 @@ resource "alicloud_instance" "foo" {
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccInstanceConfigPrivateIP = `
|
const testAccInstanceConfigPrivateIP = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -997,7 +992,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/24"
|
cidr_block = "172.16.0.0/24"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "tf_test_foo" {
|
resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
@ -1008,9 +1003,11 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
||||||
|
|
||||||
vswitch_id = "${alicloud_vswitch.foo.id}"
|
vswitch_id = "${alicloud_vswitch.foo.id}"
|
||||||
|
private_ip = "172.16.0.229"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
instance_type = "ecs.n1.medium"
|
instance_type = "ecs.n1.medium"
|
||||||
|
@ -1020,12 +1017,7 @@ resource "alicloud_instance" "foo" {
|
||||||
instance_name = "test_foo"
|
instance_name = "test_foo"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const testAccInstanceConfigAssociatePublicIP = `
|
const testAccInstanceConfigAssociatePublicIPAndPrivateIP = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -1034,7 +1026,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/24"
|
cidr_block = "172.16.0.0/24"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "tf_test_foo" {
|
resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
@ -1045,9 +1037,11 @@ resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
||||||
|
|
||||||
vswitch_id = "${alicloud_vswitch.foo.id}"
|
vswitch_id = "${alicloud_vswitch.foo.id}"
|
||||||
|
private_ip = "172.16.0.229"
|
||||||
allocate_public_ip = "true"
|
allocate_public_ip = "true"
|
||||||
internet_max_bandwidth_out = 5
|
internet_max_bandwidth_out = 5
|
||||||
internet_charge_type = "PayByBandwidth"
|
internet_charge_type = "PayByBandwidth"
|
||||||
|
@ -1061,11 +1055,6 @@ resource "alicloud_instance" "foo" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const testAccVpcInstanceWithSecurityRule = `
|
const testAccVpcInstanceWithSecurityRule = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_disk_category"= "cloud_efficiency"
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "10.1.0.0/21"
|
cidr_block = "10.1.0.0/21"
|
||||||
|
@ -1074,7 +1063,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "10.1.1.0/24"
|
cidr_block = "10.1.1.0/24"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-c"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "tf_test_foo" {
|
resource "alicloud_security_group" "tf_test_foo" {
|
||||||
|
@ -1096,6 +1085,7 @@ resource "alicloud_security_group_rule" "ingress" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-c"
|
||||||
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
security_groups = ["${alicloud_security_group.tf_test_foo.id}"]
|
||||||
|
|
||||||
vswitch_id = "${alicloud_vswitch.foo.id}"
|
vswitch_id = "${alicloud_vswitch.foo.id}"
|
||||||
|
|
|
@ -151,10 +151,6 @@ func testAccCheckNatGatewayDestroy(s *terraform.State) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccNatGatewayConfig = `
|
const testAccNatGatewayConfig = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -163,7 +159,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_nat_gateway" "foo" {
|
resource "alicloud_nat_gateway" "foo" {
|
||||||
|
@ -173,11 +169,11 @@ resource "alicloud_nat_gateway" "foo" {
|
||||||
bandwidth_packages = [{
|
bandwidth_packages = [{
|
||||||
ip_count = 1
|
ip_count = 1
|
||||||
bandwidth = 5
|
bandwidth = 5
|
||||||
zone = "${data.alicloud_zones.default.zones.0.id}"
|
zone = "cn-beijing-b"
|
||||||
}, {
|
}, {
|
||||||
ip_count = 2
|
ip_count = 2
|
||||||
bandwidth = 10
|
bandwidth = 10
|
||||||
zone = "${data.alicloud_zones.default.zones.0.id}"
|
zone = "cn-beijing-b"
|
||||||
}]
|
}]
|
||||||
depends_on = [
|
depends_on = [
|
||||||
"alicloud_vswitch.foo"]
|
"alicloud_vswitch.foo"]
|
||||||
|
@ -185,10 +181,6 @@ resource "alicloud_nat_gateway" "foo" {
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccNatGatewayConfigSpec = `
|
const testAccNatGatewayConfigSpec = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -197,7 +189,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_nat_gateway" "foo" {
|
resource "alicloud_nat_gateway" "foo" {
|
||||||
|
@ -207,11 +199,11 @@ resource "alicloud_nat_gateway" "foo" {
|
||||||
bandwidth_packages = [{
|
bandwidth_packages = [{
|
||||||
ip_count = 1
|
ip_count = 1
|
||||||
bandwidth = 5
|
bandwidth = 5
|
||||||
zone = "${data.alicloud_zones.default.zones.0.id}"
|
zone = "cn-beijing-b"
|
||||||
}, {
|
}, {
|
||||||
ip_count = 2
|
ip_count = 2
|
||||||
bandwidth = 10
|
bandwidth = 10
|
||||||
zone = "${data.alicloud_zones.default.zones.0.id}"
|
zone = "cn-beijing-b"
|
||||||
}]
|
}]
|
||||||
depends_on = [
|
depends_on = [
|
||||||
"alicloud_vswitch.foo"]
|
"alicloud_vswitch.foo"]
|
||||||
|
@ -219,10 +211,6 @@ resource "alicloud_nat_gateway" "foo" {
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccNatGatewayConfigSpecUpgrade = `
|
const testAccNatGatewayConfigSpecUpgrade = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -231,7 +219,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_nat_gateway" "foo" {
|
resource "alicloud_nat_gateway" "foo" {
|
||||||
|
@ -241,11 +229,11 @@ resource "alicloud_nat_gateway" "foo" {
|
||||||
bandwidth_packages = [{
|
bandwidth_packages = [{
|
||||||
ip_count = 1
|
ip_count = 1
|
||||||
bandwidth = 5
|
bandwidth = 5
|
||||||
zone = "${data.alicloud_zones.default.zones.0.id}"
|
zone = "cn-beijing-b"
|
||||||
}, {
|
}, {
|
||||||
ip_count = 2
|
ip_count = 2
|
||||||
bandwidth = 10
|
bandwidth = 10
|
||||||
zone = "${data.alicloud_zones.default.zones.0.id}"
|
zone = "cn-beijing-b"
|
||||||
}]
|
}]
|
||||||
depends_on = [
|
depends_on = [
|
||||||
"alicloud_vswitch.foo"]
|
"alicloud_vswitch.foo"]
|
||||||
|
|
|
@ -34,7 +34,6 @@ func resourceAliyunSecurityGroupRule() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Computed: true,
|
|
||||||
ValidateFunc: validateSecurityRuleNicType,
|
ValidateFunc: validateSecurityRuleNicType,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -162,28 +161,15 @@ func resourceAliyunSecurityGroupRuleRead(d *schema.ResourceData, meta interface{
|
||||||
|
|
||||||
func resourceAliyunSecurityGroupRuleDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAliyunSecurityGroupRuleDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*AliyunClient)
|
client := meta.(*AliyunClient)
|
||||||
ruleType := d.Get("type").(string)
|
args, err := buildAliyunSecurityIngressArgs(d, meta)
|
||||||
|
|
||||||
if GroupRuleDirection(ruleType) == GroupRuleIngress {
|
|
||||||
args, err := buildAliyunSecurityIngressArgs(d, meta)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
revokeArgs := &ecs.RevokeSecurityGroupArgs{
|
|
||||||
AuthorizeSecurityGroupArgs: *args,
|
|
||||||
}
|
|
||||||
return client.RevokeSecurityGroup(revokeArgs)
|
|
||||||
}
|
|
||||||
|
|
||||||
args, err := buildAliyunSecurityEgressArgs(d, meta)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
revokeArgs := &ecs.RevokeSecurityGroupEgressArgs{
|
revokeArgs := &ecs.RevokeSecurityGroupArgs{
|
||||||
AuthorizeSecurityGroupEgressArgs: *args,
|
AuthorizeSecurityGroupArgs: *args,
|
||||||
}
|
}
|
||||||
return client.RevokeSecurityGroupEgress(revokeArgs)
|
return client.RevokeSecurityGroup(revokeArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildAliyunSecurityIngressArgs(d *schema.ResourceData, meta interface{}) (*ecs.AuthorizeSecurityGroupArgs, error) {
|
func buildAliyunSecurityIngressArgs(d *schema.ResourceData, meta interface{}) (*ecs.AuthorizeSecurityGroupArgs, error) {
|
||||||
|
|
|
@ -81,39 +81,6 @@ func TestAccAlicloudSecurityGroupRule_Egress(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAlicloudSecurityGroupRule_EgressDefaultNicType(t *testing.T) {
|
|
||||||
var pt ecs.PermissionType
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
|
||||||
PreCheck: func() {
|
|
||||||
testAccPreCheck(t)
|
|
||||||
},
|
|
||||||
|
|
||||||
// module name
|
|
||||||
IDRefreshName: "alicloud_security_group_rule.egress",
|
|
||||||
Providers: testAccProviders,
|
|
||||||
CheckDestroy: testAccCheckSecurityGroupRuleDestroy,
|
|
||||||
Steps: []resource.TestStep{
|
|
||||||
resource.TestStep{
|
|
||||||
Config: testAccSecurityGroupRuleEgress_emptyNicType,
|
|
||||||
Check: resource.ComposeTestCheckFunc(
|
|
||||||
testAccCheckSecurityGroupRuleExists(
|
|
||||||
"alicloud_security_group_rule.egress", &pt),
|
|
||||||
resource.TestCheckResourceAttr(
|
|
||||||
"alicloud_security_group_rule.egress",
|
|
||||||
"port_range",
|
|
||||||
"80/80"),
|
|
||||||
resource.TestCheckResourceAttr(
|
|
||||||
"alicloud_security_group_rule.egress",
|
|
||||||
"nic_type",
|
|
||||||
"internet"),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAccAlicloudSecurityGroupRule_Vpc_Ingress(t *testing.T) {
|
func TestAccAlicloudSecurityGroupRule_Vpc_Ingress(t *testing.T) {
|
||||||
var pt ecs.PermissionType
|
var pt ecs.PermissionType
|
||||||
|
|
||||||
|
@ -147,43 +114,6 @@ func TestAccAlicloudSecurityGroupRule_Vpc_Ingress(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAlicloudSecurityGroupRule_MissParameterSourceCidrIp(t *testing.T) {
|
|
||||||
var pt ecs.PermissionType
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
|
||||||
PreCheck: func() {
|
|
||||||
testAccPreCheck(t)
|
|
||||||
},
|
|
||||||
|
|
||||||
// module name
|
|
||||||
IDRefreshName: "alicloud_security_group_rule.egress",
|
|
||||||
Providers: testAccProviders,
|
|
||||||
CheckDestroy: testAccCheckSecurityGroupRuleDestroy,
|
|
||||||
Steps: []resource.TestStep{
|
|
||||||
resource.TestStep{
|
|
||||||
Config: testAccSecurityGroupRule_missingSourceCidrIp,
|
|
||||||
Check: resource.ComposeTestCheckFunc(
|
|
||||||
testAccCheckSecurityGroupRuleExists(
|
|
||||||
"alicloud_security_group_rule.egress", &pt),
|
|
||||||
resource.TestCheckResourceAttr(
|
|
||||||
"alicloud_security_group_rule.egress",
|
|
||||||
"port_range",
|
|
||||||
"80/80"),
|
|
||||||
resource.TestCheckResourceAttr(
|
|
||||||
"alicloud_security_group_rule.egress",
|
|
||||||
"nic_type",
|
|
||||||
"internet"),
|
|
||||||
resource.TestCheckResourceAttr(
|
|
||||||
"alicloud_security_group_rule.egress",
|
|
||||||
"ip_protocol",
|
|
||||||
"udp"),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func testAccCheckSecurityGroupRuleExists(n string, m *ecs.PermissionType) resource.TestCheckFunc {
|
func testAccCheckSecurityGroupRuleExists(n string, m *ecs.PermissionType) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
|
@ -280,23 +210,6 @@ resource "alicloud_security_group_rule" "egress" {
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccSecurityGroupRuleEgress_emptyNicType = `
|
|
||||||
resource "alicloud_security_group" "foo" {
|
|
||||||
name = "sg_foo"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_security_group_rule" "egress" {
|
|
||||||
type = "egress"
|
|
||||||
ip_protocol = "udp"
|
|
||||||
policy = "accept"
|
|
||||||
port_range = "80/80"
|
|
||||||
priority = 1
|
|
||||||
security_group_id = "${alicloud_security_group.foo.id}"
|
|
||||||
cidr_ip = "10.159.6.18/12"
|
|
||||||
}
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
const testAccSecurityGroupRuleVpcIngress = `
|
const testAccSecurityGroupRuleVpcIngress = `
|
||||||
resource "alicloud_security_group" "foo" {
|
resource "alicloud_security_group" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.vpc.id}"
|
vpc_id = "${alicloud_vpc.vpc.id}"
|
||||||
|
@ -318,22 +231,6 @@ resource "alicloud_security_group_rule" "ingress" {
|
||||||
cidr_ip = "10.159.6.18/12"
|
cidr_ip = "10.159.6.18/12"
|
||||||
}
|
}
|
||||||
|
|
||||||
`
|
|
||||||
const testAccSecurityGroupRule_missingSourceCidrIp = `
|
|
||||||
resource "alicloud_security_group" "foo" {
|
|
||||||
name = "sg_foo"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_security_group_rule" "egress" {
|
|
||||||
security_group_id = "${alicloud_security_group.foo.id}"
|
|
||||||
type = "egress"
|
|
||||||
cidr_ip= "0.0.0.0/0"
|
|
||||||
policy = "accept"
|
|
||||||
ip_protocol= "udp"
|
|
||||||
port_range= "80/80"
|
|
||||||
priority= 1
|
|
||||||
}
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccSecurityGroupRuleMultiIngress = `
|
const testAccSecurityGroupRuleMultiIngress = `
|
||||||
|
|
|
@ -81,6 +81,7 @@ resource "alicloud_security_group" "foo" {
|
||||||
|
|
||||||
resource "alicloud_instance" "foo" {
|
resource "alicloud_instance" "foo" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
|
availability_zone = "cn-beijing-b"
|
||||||
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
|
|
|
@ -275,10 +275,6 @@ resource "alicloud_slb" "listener" {
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccSlb4Vpc = `
|
const testAccSlb4Vpc = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -287,7 +283,7 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_slb" "vpc" {
|
resource "alicloud_slb" "vpc" {
|
||||||
|
|
|
@ -92,10 +92,6 @@ func testAccCheckVswitchDestroy(s *terraform.State) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccVswitchConfig = `
|
const testAccVswitchConfig = `
|
||||||
data "alicloud_zones" "default" {
|
|
||||||
"available_resource_creation"= "VSwitch"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vpc" "foo" {
|
resource "alicloud_vpc" "foo" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
cidr_block = "172.16.0.0/12"
|
cidr_block = "172.16.0.0/12"
|
||||||
|
@ -104,6 +100,6 @@ resource "alicloud_vpc" "foo" {
|
||||||
resource "alicloud_vswitch" "foo" {
|
resource "alicloud_vswitch" "foo" {
|
||||||
vpc_id = "${alicloud_vpc.foo.id}"
|
vpc_id = "${alicloud_vpc.foo.id}"
|
||||||
cidr_block = "172.16.0.0/21"
|
cidr_block = "172.16.0.0/21"
|
||||||
availability_zone = "${data.alicloud_zones.default.zones.0.id}"
|
availability_zone = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -187,13 +187,14 @@ func (client *AliyunClient) DescribeSecurity(securityGroupId string) (*ecs.Descr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *AliyunClient) DescribeSecurityGroupRule(securityGroupId, types, ip_protocol, port_range string) (*ecs.PermissionType, error) {
|
func (client *AliyunClient) DescribeSecurityGroupRule(securityGroupId, types, ip_protocol, port_range string) (*ecs.PermissionType, error) {
|
||||||
|
|
||||||
sg, err := client.DescribeSecurity(securityGroupId)
|
sg, err := client.DescribeSecurity(securityGroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range sg.Permissions.Permission {
|
for _, p := range sg.Permissions.Permission {
|
||||||
if strings.ToLower(string(p.IpProtocol)) == ip_protocol && p.PortRange == port_range && strings.ToLower(p.Direction) == types {
|
if strings.ToLower(string(p.IpProtocol)) == ip_protocol && p.PortRange == port_range {
|
||||||
return &p, nil
|
return &p, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,11 +203,6 @@ func (client *AliyunClient) DescribeSecurityGroupRule(securityGroupId, types, ip
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *AliyunClient) RevokeSecurityGroup(args *ecs.RevokeSecurityGroupArgs) error {
|
func (client *AliyunClient) RevokeSecurityGroup(args *ecs.RevokeSecurityGroupArgs) error {
|
||||||
//when the rule is not exist, api will return success(200)
|
//todo: handle the specal err
|
||||||
return client.ecsconn.RevokeSecurityGroup(args)
|
return client.ecsconn.RevokeSecurityGroup(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *AliyunClient) RevokeSecurityGroupEgress(args *ecs.RevokeSecurityGroupEgressArgs) error {
|
|
||||||
//when the rule is not exist, api will return success(200)
|
|
||||||
return client.ecsconn.RevokeSecurityGroupEgress(args)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
### Configure NAT instance Example
|
|
||||||
|
|
||||||
In the Virtual Private Cloud(VPC) environment, to enable multiple back-end intranet hosts to provide services externally with a limited number of EIPs, map the ports on the EIP-bound host to the back-end intranet hosts.
|
|
||||||
|
|
||||||
### Get up and running
|
|
||||||
|
|
||||||
* Planning phase
|
|
||||||
|
|
||||||
terraform plan
|
|
||||||
|
|
||||||
* Apply phase
|
|
||||||
|
|
||||||
terraform apply
|
|
||||||
|
|
||||||
Get the outputs:
|
|
||||||
+ nat_instance_eip_address = 123.56.19.238
|
|
||||||
+ nat_instance_private_ip = 10.1.1.57
|
|
||||||
+ worker_instance_private_ip = 10.1.1.56
|
|
||||||
|
|
||||||
* Apply phase
|
|
||||||
|
|
||||||
+ login the vm: ssh root@123.56.19.238|Test123456
|
|
||||||
+ Run the "iptables -t nat -nvL" command to check the result
|
|
||||||
|
|
||||||
| prot | in | source | destination | |
|
|
||||||
| ---- | -- | ----------- | -------------- | ------------------------ |
|
|
||||||
| tcp | * | 0.0.0.0/0 | 10.1.1.57 | tcp dpt:80 to:10.1.1.56
|
|
||||||
| all | * | 10.1.1.0/24 | 0.0.0.0/0 | to:10.1.1.57
|
|
||||||
|
|
||||||
|
|
||||||
* Destroy
|
|
||||||
|
|
||||||
terraform destroy
|
|
|
@ -1,98 +0,0 @@
|
||||||
resource "alicloud_vpc" "main" {
|
|
||||||
cidr_block = "${var.vpc_cidr}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_vswitch" "main" {
|
|
||||||
vpc_id = "${alicloud_vpc.main.id}"
|
|
||||||
cidr_block = "${var.vswitch_cidr}"
|
|
||||||
availability_zone = "${var.zone}"
|
|
||||||
depends_on = ["alicloud_vpc.main"]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_route_entry" "entry" {
|
|
||||||
router_id = "${alicloud_vpc.main.router_id}"
|
|
||||||
route_table_id = "${alicloud_vpc.main.router_table_id}"
|
|
||||||
destination_cidrblock = "0.0.0.0/0"
|
|
||||||
nexthop_type = "Instance"
|
|
||||||
nexthop_id = "${alicloud_instance.nat.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_instance" "nat" {
|
|
||||||
image_id = "${var.image}"
|
|
||||||
instance_type = "${var.instance_nat_type}"
|
|
||||||
availability_zone = "${var.zone}"
|
|
||||||
security_groups = ["${alicloud_security_group.group.id}"]
|
|
||||||
vswitch_id = "${alicloud_vswitch.main.id}"
|
|
||||||
instance_name = "nat"
|
|
||||||
io_optimized = "optimized"
|
|
||||||
system_disk_category = "cloud_efficiency"
|
|
||||||
password= "${var.instance_pwd}"
|
|
||||||
|
|
||||||
depends_on = ["alicloud_instance.worker"]
|
|
||||||
user_data = "${data.template_file.shell.rendered}"
|
|
||||||
|
|
||||||
tags {
|
|
||||||
Name = "ecs-nat"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data "template_file" "shell" {
|
|
||||||
template = "${file("userdata.sh")}"
|
|
||||||
|
|
||||||
vars {
|
|
||||||
worker_private_ip = "${alicloud_instance.worker.private_ip}"
|
|
||||||
vswitch_cidr = "${var.vswitch_cidr}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_instance" "worker" {
|
|
||||||
image_id = "${var.image}"
|
|
||||||
instance_type = "${var.instance_worker_type}"
|
|
||||||
availability_zone = "${var.zone}"
|
|
||||||
security_groups = ["${alicloud_security_group.group.id}"]
|
|
||||||
vswitch_id = "${alicloud_vswitch.main.id}"
|
|
||||||
instance_name = "worker"
|
|
||||||
io_optimized = "optimized"
|
|
||||||
system_disk_category = "cloud_efficiency"
|
|
||||||
password= "${var.instance_pwd}"
|
|
||||||
|
|
||||||
tags {
|
|
||||||
Name = "ecs-worker"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_eip" "eip" {
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_eip_association" "attach" {
|
|
||||||
allocation_id = "${alicloud_eip.eip.id}"
|
|
||||||
instance_id = "${alicloud_instance.nat.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_security_group" "group" {
|
|
||||||
name = "terraform-test-group"
|
|
||||||
description = "New security group"
|
|
||||||
vpc_id = "${alicloud_vpc.main.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_security_group_rule" "allow_in" {
|
|
||||||
security_group_id = "${alicloud_security_group.group.id}"
|
|
||||||
type = "ingress"
|
|
||||||
cidr_ip= "0.0.0.0/0"
|
|
||||||
policy = "accept"
|
|
||||||
ip_protocol= "all"
|
|
||||||
nic_type= "intranet"
|
|
||||||
port_range= "-1/-1"
|
|
||||||
priority= 1
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_security_group_rule" "allow_out" {
|
|
||||||
security_group_id = "${alicloud_security_group.group.id}"
|
|
||||||
type = "egress"
|
|
||||||
cidr_ip= "0.0.0.0/0"
|
|
||||||
policy = "accept"
|
|
||||||
ip_protocol= "all"
|
|
||||||
nic_type= "intranet"
|
|
||||||
port_range= "-1/-1"
|
|
||||||
priority= 1
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
output "nat_instance_id" {
|
|
||||||
value = "${alicloud_instance.nat.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "nat_instance_private_ip" {
|
|
||||||
value = "${alicloud_instance.nat.private_ip}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "nat_instance_eip_address" {
|
|
||||||
value = "${alicloud_eip.eip.ip_address}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "worker_instance_id" {
|
|
||||||
value = "${alicloud_instance.worker.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "worker_instance_private_ip" {
|
|
||||||
value = "${alicloud_instance.worker.private_ip}"
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
PostRouting=${vswitch_cidr}
|
|
||||||
SourceRouting=`ifconfig eth0|grep inet|awk '{print $2}'|tr -d 'addr:'`
|
|
||||||
echo ${worker_private_ip}>> /etc/sysctl.conf
|
|
||||||
echo 'net.ipv4.ip_forward=1'>> /etc/sysctl.conf
|
|
||||||
sysctl -p
|
|
||||||
iptables -t nat -I POSTROUTING -s $PostRouting -j SNAT --to-source $SourceRouting
|
|
||||||
iptables -t nat -I PREROUTING -d $SourceRouting -p tcp --dport 80 -j DNAT --to ${worker_private_ip}
|
|
|
@ -1,27 +0,0 @@
|
||||||
variable "vpc_cidr" {
|
|
||||||
default = "10.1.0.0/21"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vswitch_cidr" {
|
|
||||||
default = "10.1.1.0/24"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "zone" {
|
|
||||||
default = "cn-beijing-c"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "image" {
|
|
||||||
default = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "instance_nat_type" {
|
|
||||||
default = "ecs.n1.small"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "instance_worker_type" {
|
|
||||||
default = "ecs.s2.large"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "instance_pwd" {
|
|
||||||
default = "Test123456"
|
|
||||||
}
|
|
|
@ -11,38 +11,27 @@ resource "alicloud_vswitch" "vsw" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_security_group" "sg" {
|
resource "alicloud_security_group" "sg" {
|
||||||
name = "tf-sg"
|
name = "tf-sg"
|
||||||
description = "sg"
|
description = "sg"
|
||||||
vpc_id = "${alicloud_vpc.default.id}"
|
vpc_id = "${alicloud_vpc.default.id}"
|
||||||
}
|
|
||||||
|
|
||||||
resource "alicloud_security_group_rule" "allow_ssh" {
|
|
||||||
security_group_id = "${alicloud_security_group.sg.id}"
|
|
||||||
type = "ingress"
|
|
||||||
cidr_ip= "0.0.0.0/0"
|
|
||||||
policy = "accept"
|
|
||||||
ip_protocol= "tcp"
|
|
||||||
port_range= "22/22"
|
|
||||||
priority= 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_instance" "website" {
|
resource "alicloud_instance" "website" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
availability_zone = "${var.zone}"
|
availability_zone = "${var.zone}"
|
||||||
vswitch_id = "${alicloud_vswitch.vsw.id}"
|
vswitch_id = "${alicloud_vswitch.vsw.id}"
|
||||||
image_id = "${var.image}"
|
image_id = "${var.image}"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
instance_type = "${var.ecs_type}"
|
instance_type = "${var.ecs_type}"
|
||||||
io_optimized = "optimized"
|
io_optimized = "optimized"
|
||||||
system_disk_category = "cloud_efficiency"
|
system_disk_category = "cloud_efficiency"
|
||||||
|
|
||||||
internet_charge_type = "PayByTraffic"
|
internet_charge_type = "PayByTraffic"
|
||||||
internet_max_bandwidth_out = 5
|
internet_max_bandwidth_out = 5
|
||||||
allocate_public_ip = true
|
allocate_public_ip = true
|
||||||
security_groups = ["${alicloud_security_group.sg.id}"]
|
security_groups = ["${alicloud_security_group.sg.id}"]
|
||||||
instance_name = "tf_website"
|
instance_name = "test_foo"
|
||||||
password= "${var.password}"
|
|
||||||
|
|
||||||
user_data = "${file("userdata.sh")}"
|
user_data = "${file("userdata.sh")}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
output "hostname" {
|
||||||
|
value = "${alicloud_instance.website.instance_name}"
|
||||||
|
}
|
||||||
|
|
||||||
output "ecs_id" {
|
output "ecs_id" {
|
||||||
value = "${alicloud_instance.website.id}"
|
value = "${alicloud_instance.website.id}"
|
||||||
}
|
|
||||||
|
|
||||||
output "ecs_public_ip" {
|
|
||||||
value = "${alicloud_instance.website.public_ip}"
|
|
||||||
}
|
}
|
|
@ -10,10 +10,6 @@ variable "zone" {
|
||||||
default = "cn-beijing-b"
|
default = "cn-beijing-b"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "password" {
|
|
||||||
default = "Test123456"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "image" {
|
variable "image" {
|
||||||
default = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
default = "ubuntu_140405_32_40G_cloudinit_20161115.vhd"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ data "alicloud_instance_types" "1c2g" {
|
||||||
}
|
}
|
||||||
|
|
||||||
data "alicloud_zones" "default" {
|
data "alicloud_zones" "default" {
|
||||||
"available_instance_type"= "${data.alicloud_instance_types.1c2g.instance_types.0.id}"
|
"available_instance_type"= "${data.alicloud_instance_types.4c8g.instance_types.0.id}"
|
||||||
"available_disk_category"= "${var.disk_category}"
|
"available_disk_category"= "${var.disk_category}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ resource "alicloud_security_group" "group" {
|
||||||
|
|
||||||
|
|
||||||
resource "alicloud_disk" "disk" {
|
resource "alicloud_disk" "disk" {
|
||||||
availability_zone = "${alicloud_instance.instance.0.availability_zone}"
|
availability_zone = "${var.availability_zones}"
|
||||||
category = "${var.disk_category}"
|
category = "${var.disk_category}"
|
||||||
size = "${var.disk_size}"
|
size = "${var.disk_size}"
|
||||||
count = "${var.count}"
|
count = "${var.count}"
|
||||||
|
@ -17,6 +17,7 @@ resource "alicloud_instance" "instance" {
|
||||||
image_id = "${var.image_id}"
|
image_id = "${var.image_id}"
|
||||||
instance_type = "${var.ecs_type}"
|
instance_type = "${var.ecs_type}"
|
||||||
count = "${var.count}"
|
count = "${var.count}"
|
||||||
|
availability_zone = "${var.availability_zones}"
|
||||||
security_groups = ["${alicloud_security_group.group.*.id}"]
|
security_groups = ["${alicloud_security_group.group.*.id}"]
|
||||||
|
|
||||||
internet_charge_type = "${var.internet_charge_type}"
|
internet_charge_type = "${var.internet_charge_type}"
|
||||||
|
|
|
@ -23,6 +23,9 @@ variable "ecs_type" {
|
||||||
variable "ecs_password" {
|
variable "ecs_password" {
|
||||||
default = "Test12345"
|
default = "Test12345"
|
||||||
}
|
}
|
||||||
|
variable "availability_zones" {
|
||||||
|
default = "cn-beijing-b"
|
||||||
|
}
|
||||||
variable "allocate_public_ip" {
|
variable "allocate_public_ip" {
|
||||||
default = true
|
default = true
|
||||||
}
|
}
|
||||||
|
@ -38,7 +41,7 @@ variable "io_optimized" {
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "disk_category" {
|
variable "disk_category" {
|
||||||
default = "cloud_efficiency"
|
default = "cloud_ssd"
|
||||||
}
|
}
|
||||||
variable "disk_size" {
|
variable "disk_size" {
|
||||||
default = "40"
|
default = "40"
|
||||||
|
|
|
@ -128,8 +128,7 @@ func (client *Client) Invoke(action string, args interface{}, response interface
|
||||||
|
|
||||||
// Invoke sends the raw HTTP request for ECS services
|
// Invoke sends the raw HTTP request for ECS services
|
||||||
//改进了一下上面那个方法,可以使用各种Http方法
|
//改进了一下上面那个方法,可以使用各种Http方法
|
||||||
//2017.1.30 增加了一个path参数,用来拓展访问的地址
|
func (client *Client) InvokeByAnyMethod(method, action string, args interface{}, response interface{}) error {
|
||||||
func (client *Client) InvokeByAnyMethod(method, action, path string, args interface{}, response interface{}) error {
|
|
||||||
|
|
||||||
request := Request{}
|
request := Request{}
|
||||||
request.init(client.version, action, client.AccessKeyId)
|
request.init(client.version, action, client.AccessKeyId)
|
||||||
|
@ -141,18 +140,17 @@ func (client *Client) InvokeByAnyMethod(method, action, path string, args interf
|
||||||
signature := util.CreateSignatureForRequest(method, &data, client.AccessKeySecret)
|
signature := util.CreateSignatureForRequest(method, &data, client.AccessKeySecret)
|
||||||
|
|
||||||
data.Add("Signature", signature)
|
data.Add("Signature", signature)
|
||||||
|
|
||||||
// Generate the request URL
|
// Generate the request URL
|
||||||
var (
|
var (
|
||||||
httpReq *http.Request
|
httpReq *http.Request
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if method == http.MethodGet {
|
if method == http.MethodGet {
|
||||||
requestURL := client.endpoint + path + "?" + data.Encode()
|
requestURL := client.endpoint + "?" + data.Encode()
|
||||||
//fmt.Println(requestURL)
|
|
||||||
httpReq, err = http.NewRequest(method, requestURL, nil)
|
httpReq, err = http.NewRequest(method, requestURL, nil)
|
||||||
} else {
|
} else {
|
||||||
//fmt.Println(client.endpoint + path)
|
httpReq, err = http.NewRequest(method, client.endpoint, strings.NewReader(data.Encode()))
|
||||||
httpReq, err = http.NewRequest(method, client.endpoint + path, strings.NewReader(data.Encode()))
|
|
||||||
httpReq.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
httpReq.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,6 @@ func (client *Client) DescribeImages(args *DescribeImagesArgs) (images []ImageTy
|
||||||
type CreateImageArgs struct {
|
type CreateImageArgs struct {
|
||||||
RegionId common.Region
|
RegionId common.Region
|
||||||
SnapshotId string
|
SnapshotId string
|
||||||
InstanceId string
|
|
||||||
ImageName string
|
ImageName string
|
||||||
ImageVersion string
|
ImageVersion string
|
||||||
Description string
|
Description string
|
||||||
|
|
|
@ -15,14 +15,12 @@ type InstanceStatus string
|
||||||
|
|
||||||
// Constants of InstanceStatus
|
// Constants of InstanceStatus
|
||||||
const (
|
const (
|
||||||
Creating = InstanceStatus("Creating") // For backward compatability
|
Creating = InstanceStatus("Creating")
|
||||||
Pending = InstanceStatus("Pending")
|
|
||||||
Running = InstanceStatus("Running")
|
Running = InstanceStatus("Running")
|
||||||
Starting = InstanceStatus("Starting")
|
Starting = InstanceStatus("Starting")
|
||||||
|
|
||||||
Stopped = InstanceStatus("Stopped")
|
Stopped = InstanceStatus("Stopped")
|
||||||
Stopping = InstanceStatus("Stopping")
|
Stopping = InstanceStatus("Stopping")
|
||||||
Deleted = InstanceStatus("Deleted")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type LockReason string
|
type LockReason string
|
||||||
|
@ -281,7 +279,6 @@ type ModifyInstanceAttributeArgs struct {
|
||||||
Description string
|
Description string
|
||||||
Password string
|
Password string
|
||||||
HostName string
|
HostName string
|
||||||
UserData string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModifyInstanceAttributeResponse struct {
|
type ModifyInstanceAttributeResponse struct {
|
||||||
|
@ -326,37 +323,6 @@ func (client *Client) WaitForInstance(instanceId string, status InstanceStatus,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForInstance waits for instance to given status
|
|
||||||
// when instance.NotFound wait until timeout
|
|
||||||
func (client *Client) WaitForInstanceAsyn(instanceId string, status InstanceStatus, timeout int) error {
|
|
||||||
if timeout <= 0 {
|
|
||||||
timeout = InstanceDefaultTimeout
|
|
||||||
}
|
|
||||||
for {
|
|
||||||
instance, err := client.DescribeInstanceAttribute(instanceId)
|
|
||||||
if err != nil {
|
|
||||||
e, _ := err.(*common.Error)
|
|
||||||
if e.ErrorResponse.Code != "InvalidInstanceId.NotFound" {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if instance.Status == status {
|
|
||||||
//TODO
|
|
||||||
//Sleep one more time for timing issues
|
|
||||||
time.Sleep(DefaultWaitForInterval * time.Second)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
timeout = timeout - DefaultWaitForInterval
|
|
||||||
if timeout <= 0 {
|
|
||||||
return common.GetClientErrorFromString("Timeout")
|
|
||||||
}
|
|
||||||
time.Sleep(DefaultWaitForInterval * time.Second)
|
|
||||||
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type DescribeInstanceVncUrlArgs struct {
|
type DescribeInstanceVncUrlArgs struct {
|
||||||
RegionId common.Region
|
RegionId common.Region
|
||||||
InstanceId string
|
InstanceId string
|
||||||
|
@ -544,43 +510,6 @@ func (client *Client) CreateInstance(args *CreateInstanceArgs) (instanceId strin
|
||||||
return response.InstanceId, err
|
return response.InstanceId, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type RunInstanceArgs struct {
|
|
||||||
CreateInstanceArgs
|
|
||||||
MinAmount int
|
|
||||||
MaxAmount int
|
|
||||||
AutoReleaseTime string
|
|
||||||
NetworkType string
|
|
||||||
InnerIpAddress string
|
|
||||||
BusinessInfo string
|
|
||||||
}
|
|
||||||
|
|
||||||
type RunInstanceResponse struct {
|
|
||||||
common.Response
|
|
||||||
InstanceIdSets InstanceIdSets
|
|
||||||
}
|
|
||||||
|
|
||||||
type InstanceIdSets struct {
|
|
||||||
InstanceIdSet []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type BusinessInfo struct {
|
|
||||||
Pack string `json:"pack,omitempty" yaml:"pack,omitempty"`
|
|
||||||
ActivityId string `json:"activityId,omitempty" yaml:"activityId,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) RunInstances(args *RunInstanceArgs) (instanceIdSet []string, err error) {
|
|
||||||
if args.UserData != "" {
|
|
||||||
// Encode to base64 string
|
|
||||||
args.UserData = base64.StdEncoding.EncodeToString([]byte(args.UserData))
|
|
||||||
}
|
|
||||||
response := RunInstanceResponse{}
|
|
||||||
err = client.Invoke("RunInstances", args, &response)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return response.InstanceIdSets.InstanceIdSet, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type SecurityGroupArgs struct {
|
type SecurityGroupArgs struct {
|
||||||
InstanceId string
|
InstanceId string
|
||||||
SecurityGroupId string
|
SecurityGroupId string
|
||||||
|
|
|
@ -1,126 +0,0 @@
|
||||||
package slb
|
|
||||||
|
|
||||||
import "github.com/denverdino/aliyungo/common"
|
|
||||||
|
|
||||||
type CreateRulesResponse struct {
|
|
||||||
common.Response
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateRulesArgs struct {
|
|
||||||
RegionId common.Region
|
|
||||||
LoadBalancerId string
|
|
||||||
ListenerPort int
|
|
||||||
RuleList string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Rule struct {
|
|
||||||
RuleId string
|
|
||||||
RuleName string
|
|
||||||
Domain string
|
|
||||||
Url string
|
|
||||||
VServerGroupId string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create forward rules
|
|
||||||
//
|
|
||||||
// You can read doc at https://help.aliyun.com/document_detail/35226.html?spm=5176.doc35226.6.671.625Omh
|
|
||||||
func (client *Client) CreateRules(args *CreateRulesArgs) error {
|
|
||||||
response := CreateRulesResponse{}
|
|
||||||
err := client.Invoke("CreateRules", args, &response)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteRulesArgs struct {
|
|
||||||
RegionId common.Region
|
|
||||||
RuleIds string
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteRulesResponse struct {
|
|
||||||
common.Response
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete forward rules
|
|
||||||
//
|
|
||||||
// You can read doc at https://help.aliyun.com/document_detail/35227.html?spm=5176.doc35226.6.672.6iNBtR
|
|
||||||
func (client *Client) DeleteRules(args *DeleteRulesArgs) error {
|
|
||||||
response := DeleteRulesResponse{}
|
|
||||||
err := client.Invoke("DeleteRules", args, &response)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetRuleArgs struct {
|
|
||||||
RegionId common.Region
|
|
||||||
RuleId string
|
|
||||||
VServerGroupId string
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetRuleResponse struct {
|
|
||||||
common.Response
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modify forward rules
|
|
||||||
//
|
|
||||||
// You can read doc at https://help.aliyun.com/document_detail/35228.html?spm=5176.doc35227.6.673.rq40a9
|
|
||||||
func (client *Client) SetRule(args *SetRuleArgs) error {
|
|
||||||
response := SetRuleResponse{}
|
|
||||||
err := client.Invoke("SetRule", args, &response)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
type DescribeRuleAttributeArgs struct {
|
|
||||||
RegionId common.Region
|
|
||||||
RuleId string
|
|
||||||
}
|
|
||||||
|
|
||||||
type DescribeRuleAttributeResponse struct {
|
|
||||||
common.Response
|
|
||||||
LoadBalancerId string
|
|
||||||
ListenerPort int
|
|
||||||
Rule
|
|
||||||
}
|
|
||||||
|
|
||||||
// Describe rule
|
|
||||||
//
|
|
||||||
// You can read doc at https://help.aliyun.com/document_detail/35229.html?spm=5176.doc35226.6.674.DRJeKJ
|
|
||||||
func (client *Client) DescribeRuleAttribute(args *DescribeRuleAttributeArgs) (*DescribeRuleAttributeResponse, error) {
|
|
||||||
response := &DescribeRuleAttributeResponse{}
|
|
||||||
err := client.Invoke("DescribeRuleAttribute", args, response)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type DescribeRulesArgs struct {
|
|
||||||
RegionId common.Region
|
|
||||||
LoadBalancerId string
|
|
||||||
ListenerPort int
|
|
||||||
}
|
|
||||||
|
|
||||||
type DescribeRulesResponse struct {
|
|
||||||
common.Response
|
|
||||||
Rules struct {
|
|
||||||
Rule []Rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Describe rule
|
|
||||||
//
|
|
||||||
// You can read doc at https://help.aliyun.com/document_detail/35229.html?spm=5176.doc35226.6.674.DRJeKJ
|
|
||||||
func (client *Client) DescribeRules(args *DescribeRulesArgs) (*DescribeRulesResponse, error) {
|
|
||||||
response := &DescribeRulesResponse{}
|
|
||||||
err := client.Invoke("DescribeRules", args, response)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return response, nil
|
|
||||||
}
|
|
|
@ -1292,28 +1292,28 @@
|
||||||
"revisionTime": "2016-10-29T20:57:26Z"
|
"revisionTime": "2016-10-29T20:57:26Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "e6yzSIwLwJV0tb2YQupLL0FO1BM=",
|
"checksumSHA1": "ADySw3nBHyzEHB6afBSeVRN2A4g=",
|
||||||
"path": "github.com/denverdino/aliyungo/common",
|
"path": "github.com/denverdino/aliyungo/common",
|
||||||
"revision": "c0ff6df91f593ae8b30f749cc949b4588d8c96c9",
|
"revision": "d123f5d1fa71b211b70b2e9b56a62da21076884a",
|
||||||
"revisionTime": "2017-02-23T12:23:33Z"
|
"revisionTime": "2017-01-17T10:57:15Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "YLooG/WAFF61eBUxg/R5cpfi5DE=",
|
"checksumSHA1": "9ZY3RlumKp5DAMfL08YwMoOOT2o=",
|
||||||
"path": "github.com/denverdino/aliyungo/ecs",
|
"path": "github.com/denverdino/aliyungo/ecs",
|
||||||
"revision": "c0ff6df91f593ae8b30f749cc949b4588d8c96c9",
|
"revision": "d123f5d1fa71b211b70b2e9b56a62da21076884a",
|
||||||
"revisionTime": "2017-02-23T12:23:33Z"
|
"revisionTime": "2017-01-17T10:57:15Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "mF2UQ4+NJrPUZkm1RNa9Kxr2U0s=",
|
"checksumSHA1": "QlA7zv05k7HWeR3tg4uHqIlFcg8=",
|
||||||
"path": "github.com/denverdino/aliyungo/slb",
|
"path": "github.com/denverdino/aliyungo/slb",
|
||||||
"revision": "c0ff6df91f593ae8b30f749cc949b4588d8c96c9",
|
"revision": "d123f5d1fa71b211b70b2e9b56a62da21076884a",
|
||||||
"revisionTime": "2017-02-23T12:23:33Z"
|
"revisionTime": "2017-01-17T10:57:15Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Lp0KtT7ycgq31ox3Uzhpxyw0U+Y=",
|
"checksumSHA1": "Lp0KtT7ycgq31ox3Uzhpxyw0U+Y=",
|
||||||
"path": "github.com/denverdino/aliyungo/util",
|
"path": "github.com/denverdino/aliyungo/util",
|
||||||
"revision": "c0ff6df91f593ae8b30f749cc949b4588d8c96c9",
|
"revision": "d123f5d1fa71b211b70b2e9b56a62da21076884a",
|
||||||
"revisionTime": "2017-02-23T12:23:33Z"
|
"revisionTime": "2017-01-17T10:57:15Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "yDQQpeUxwqB3C+4opweg6znWJQk=",
|
"checksumSHA1": "yDQQpeUxwqB3C+4opweg6znWJQk=",
|
||||||
|
|
|
@ -15,38 +15,38 @@ Provides a ECS instance resource.
|
||||||
```
|
```
|
||||||
# Create a new ECS instance for classic
|
# Create a new ECS instance for classic
|
||||||
resource "alicloud_security_group" "classic" {
|
resource "alicloud_security_group" "classic" {
|
||||||
name = "tf_test_foo"
|
name = "tf_test_foo"
|
||||||
description = "foo"
|
description = "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_instance" "classic" {
|
resource "alicloud_instance" "classic" {
|
||||||
# cn-beijing
|
# cn-beijing
|
||||||
availability_zone = "cn-beijing-b"
|
availability_zone = "cn-beijing-b"
|
||||||
security_group_id = "${alicloud_security_group.classic.id}"
|
security_group_id = "${alicloud_security_group.classic.id}"
|
||||||
|
|
||||||
allocate_public_ip = "true"
|
allocate_public_ip = "true"
|
||||||
|
|
||||||
# series II
|
# series II
|
||||||
instance_type = "ecs.n1.medium"
|
instance_type = "ecs.n1.medium"
|
||||||
io_optimized = "optimized"
|
io_optimized = "optimized"
|
||||||
system_disk_category = "cloud_efficiency"
|
system_disk_category = "cloud_efficiency"
|
||||||
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
||||||
instance_name = "test_foo"
|
instance_name = "test_foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a new ECS instance for VPC
|
# Create a new ECS instance for VPC
|
||||||
resource "alicloud_vpc" "default" {
|
resource "alicloud_vpc" "default" {
|
||||||
# Other parameters...
|
# Other parameters...
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_vswitch" "default" {
|
resource "alicloud_vswitch" "default" {
|
||||||
# Other parameters...
|
# Other parameters...
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "alicloud_slb" "vpc" {
|
resource "alicloud_slb" "vpc" {
|
||||||
name = "test-slb-tf"
|
name = "test-slb-tf"
|
||||||
vpc_id = "${alicloud_vpc.default.id}"
|
vpc_id = "${alicloud_vpc.default.id}"
|
||||||
vswitch_id = "${alicloud_vswitch.default.id}"
|
vswitch_id = "${alicloud_vswitch.default.id}"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -54,20 +54,22 @@ resource "alicloud_slb" "vpc" {
|
||||||
|
|
||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
|
* `availability_zone` - (Required) The Zone to start the instance in.
|
||||||
* `image_id` - (Required) The Image to use for the instance.
|
* `image_id` - (Required) The Image to use for the instance.
|
||||||
* `instance_type` - (Required) The type of instance to start.
|
* `instance_type` - (Required) The type of instance to start.
|
||||||
* `io_optimized` - (Required) Valid values are `none`, `optimized`, If `optimized`, the launched ECS instance will be I/O optimized.
|
* `security_group_ids` - (Required) A list of security group ids to associate with. If you are creating Instances in a VPC, use `vpc_security_group_ids` instead.
|
||||||
* `security_group_ids` - (Optional) A list of security group ids to associate with.
|
`security_group_ids` instead.
|
||||||
* `availability_zone` - (Optional) The Zone to start the instance in.
|
* `instance_name` - (Optional) The name of the ECS. This instance_name can have a string of 2 to 128 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin or end with a hyphen, and must not begin with http:// or https://. If not specified,
|
||||||
* `instance_name` - (Optional) The name of the ECS. This instance_name can have a string of 2 to 128 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin or end with a hyphen, and must not begin with http:// or https://. If not specified,
|
Terraform will autogenerate a name beginning with `tf-ecs`.
|
||||||
Terraform will autogenerate a default name is `ECS-Instance`.
|
|
||||||
* `allocate_public_ip` - (Optional) Associate a public ip address with an instance in a VPC or Classic. Boolean value, Default is false.
|
* `allocate_public_ip` - (Optional) Associate a public ip address with an instance in a VPC or Classic. Boolean value, Default is false.
|
||||||
* `system_disk_category` - (Optional) Valid values are `cloud`, `cloud_efficiency`, `cloud_ssd`, For I/O optimized instance type, `cloud_ssd` and `cloud_efficiency` disks are supported. For non I/O Optimized instance type, `cloud` disk are supported.
|
* `io_optimized` - (Optional) Valid
|
||||||
|
values are `none`, `optimized`, If `optimized`, the launched ECS instance will be I/O optimized. Default is `optimized`.
|
||||||
|
* `system_disk_category` - (Optional) Valid values are `cloud`, `cloud_efficiency`, `cloud_ssd`, For I/O optimized instance type, `cloud_ssd` and `cloud_efficiency` disks are supported. For non I/O Optimized instance type, `cloud` disk are supported.
|
||||||
* `system_disk_size` - (Optional) Size of the system disk, value range: 40GB ~ 500GB. Default is 40GB.
|
* `system_disk_size` - (Optional) Size of the system disk, value range: 40GB ~ 500GB. Default is 40GB.
|
||||||
* `description` - (Optional) Description of the instance, This description can have a string of 2 to 256 characters, It cannot begin with http:// or https://. Default value is null.
|
* `description` - (Optional) Description of the instance, This description can have a string of 2 to 256 characters, It cannot begin with http:// or https://. Default value is null.
|
||||||
* `internet_charge_type` - (Optional) Internet charge type of the instance, Valid values are `PayByBandwidth`, `PayByTraffic`. Default is `PayByBandwidth`.
|
* `internet_charge_type` - (Optional) Internet charge type of the instance, Valid values are `PayByBandwidth`, `PayByTraffic`. Default is `PayByBandwidth`.
|
||||||
* `internet_max_bandwidth_in` - (Optional) Maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second). Value range: [1, 200]. If this value is not specified, then automatically sets it to 200 Mbps.
|
* `internet_max_bandwidth_in` - (Optional) Maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second). Value range: [1, 200]. If this value is not specified, then automatically sets it to 200 Mbps.
|
||||||
* `internet_max_bandwidth_out` - (Optional) Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). Value range:
|
* `internet_max_bandwidth_out` - (Optional) Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). Value range:
|
||||||
`internet_charge_type` is `PayByBandwidth`: this value range [0, 100], If this value is not specified, then automatically sets it to 0 Mbps; If `internet_charge_type` is `PayByTraffic`: this value range [1, 100]. this value must be set value, such as 5.
|
`internet_charge_type` is `PayByBandwidth`: this value range [0, 100], If this value is not specified, then automatically sets it to 0 Mbps; If `internet_charge_type` is `PayByTraffic`: this value range [1, 100]. this value must be set value, such as 5.
|
||||||
* `host_name` - (Optional) Host name of the ECS, which is a string of at least two characters. “hostname” cannot start or end with “.” or “-“. In addition, two or more consecutive “.” or “-“ symbols are not allowed. On Windows, the host name can contain a maximum of 15 characters, which can be a combination of uppercase/lowercase letters, numerals, and “-“. The host name cannot contain dots (“.”) or contain only numeric characters.
|
* `host_name` - (Optional) Host name of the ECS, which is a string of at least two characters. “hostname” cannot start or end with “.” or “-“. In addition, two or more consecutive “.” or “-“ symbols are not allowed. On Windows, the host name can contain a maximum of 15 characters, which can be a combination of uppercase/lowercase letters, numerals, and “-“. The host name cannot contain dots (“.”) or contain only numeric characters.
|
||||||
On other OSs such as Linux, the host name can contain a maximum of 30 characters, which can be segments separated by dots (“.”), where each segment can contain uppercase/lowercase letters, numerals, or “_“.
|
On other OSs such as Linux, the host name can contain a maximum of 30 characters, which can be segments separated by dots (“.”), where each segment can contain uppercase/lowercase letters, numerals, or “_“.
|
||||||
|
@ -75,6 +77,7 @@ On other OSs such as Linux, the host name can contain a maximum of 30 characters
|
||||||
* `vswitch_id` - (Optional) The virtual switch ID to launch in VPC. If you want to create instances in VPC network, this parameter must be set.
|
* `vswitch_id` - (Optional) The virtual switch ID to launch in VPC. If you want to create instances in VPC network, this parameter must be set.
|
||||||
* `instance_charge_type` - (Optional) Valid values are `PrePaid`, `PostPaid`, The default is `PostPaid`.
|
* `instance_charge_type` - (Optional) Valid values are `PrePaid`, `PostPaid`, The default is `PostPaid`.
|
||||||
* `period` - (Optional) The time that you have bought the resource, in month. Only valid when instance_charge_type is set as `PrePaid`. Value range [1, 12].
|
* `period` - (Optional) The time that you have bought the resource, in month. Only valid when instance_charge_type is set as `PrePaid`. Value range [1, 12].
|
||||||
|
* `private_ip` - (Optional) Private IP address to associate with the instance in a VPC.
|
||||||
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
Loading…
Reference in New Issue