Skip to content

Commit

Permalink
add new resource for rds, like account, database and so on
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Jan 3, 2018
1 parent 3d535cb commit 8a69e75
Show file tree
Hide file tree
Showing 34 changed files with 2,158 additions and 978 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ terraform.log
glide.lock
.DS_Store
.idea
*.pem
*.pem
*.backup
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
## 1.6.0 (unreleased)

## 1.5.0 (December 29, 2017)
## 1.5.0 (January 3, 2018)

FEATURES:

* **New Resource:** `alicloud_db_account` ([#324](https://github.com/alibaba/terraform-provider/pull/324))
* **New Resource:** `alicloud_db_account_privilege` ([#324](https://github.com/alibaba/terraform-provider/pull/324))
* **New Resource:** `alicloud_db_backup_policy` ([#324](https://github.com/alibaba/terraform-provider/pull/324))
* **New Resource:** `alicloud_db_connection` ([#324](https://github.com/alibaba/terraform-provider/pull/324))
* **New Resource:** `alicloud_db_database` ([#324](https://github.com/alibaba/terraform-provider/pull/324))


IMPROVMENTS:
* support to modify instance spec including instnaceType, bandwidth ([#322](https://github.com/alibaba/terraform-provider/pull/322))
* support to modify instance privateIp and vswitch ([#322](https://github.com/alibaba/terraform-provider/pull/322))
* support to modify instance charge type ([#322](https://github.com/alibaba/terraform-provider/pull/322))
* output more useful error message ([#322](https://github.com/alibaba/terraform-provider/pull/322))
* support to modify load balance internet attribute ([#323](https://github.com/alibaba/terraform-provider/pull/323))
* modify `alicloud_db_instance` ([#324](https://github.com/alibaba/terraform-provider/pull/324))


BUG FIXES:
* fix SLB not found when describing SLB ([#322](https://github.com/alibaba/terraform-provider/pull/322))
* fix attaching disk failed ([#323](https://github.com/alibaba/terraform-provider/pull/323))
* fix dns record deleting failed ([#324](https://github.com/alibaba/terraform-provider/pull/324))

## 1.3.3 (December 14, 2017)

Expand Down
32 changes: 32 additions & 0 deletions alicloud/diff_suppress_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package alicloud
import (
"github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/dns"
"github.com/denverdino/aliyungo/rds"
"github.com/denverdino/aliyungo/slb"
"github.com/hashicorp/terraform/helper/schema"
"strconv"
)

func httpHttpsDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
Expand Down Expand Up @@ -135,3 +137,33 @@ func ecsChargeTypeSuppressFunc(k, old, new string, d *schema.ResourceData) bool
}
return false
}

func zoneIdDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
if vsw, ok := d.GetOk("vswitch_id"); ok && vsw.(string) != "" {
return true
} else if vsw, ok := d.GetOk("subnet_id"); ok && vsw.(string) != "" {
return true
} else if multi, ok := d.GetOk("multi_az"); ok && multi.(bool) {
return true
}
return false
}

func logRetentionPeriodDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
if d.Get("log_backup").(bool) {
return false
}

if v, err := strconv.Atoi(new); err != nil && v > d.Get("retention_period").(int) {
return false
}

return true
}

func rdsPostPaidDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
if rds.DBPayType(d.Get("instance_charge_type").(string)) == rds.Prepaid {
return false
}
return true
}
14 changes: 12 additions & 2 deletions alicloud/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const (
InstanceLockedForSecurity = "InstanceLockedForSecurity"
SystemDiskNotFound = "SystemDiskNotFound"
DiskOperationConflict = "OperationConflict"
DiskInternalError = "InternalError"
DiskInvalidOperation = "InvalidOperation.Conflict"
DiskInternalError = "InternalError"
DiskInvalidOperation = "InvalidOperation.Conflict"
// eip
EipIncorrectStatus = "IncorrectEipStatus"
InstanceIncorrectStatus = "IncorrectInstanceStatus"
Expand Down Expand Up @@ -56,6 +56,16 @@ const (
IncorrectScalingConfigurationLifecycleState = "IncorrectScalingConfigurationLifecycleState"
IncorrectScalingGroupStatus = "IncorrectScalingGroupStatus"

// rds
InvalidDBNameNotFound = "InvalidDBName.NotFound"
InvalidDBInstanceNameNotFound = "InvalidDBInstanceName.NotFound"
InvalidCurrentConnectionStringNotFound = "InvalidCurrentConnectionString.NotFound"
NetTypeExists = "NetTypeExists"
InvalidAccountNameDuplicate = "InvalidAccountName.Duplicate"
InvalidAccountNameNotFound = "InvalidAccountName.NotFound"
OperationDeniedDBInstanceStatus = "OperationDenied.DBInstanceStatus"
InvalidConnectionStringDuplicate = "InvalidConnectionString.Duplicate"
AtLeastOneNetTypeExists = "AtLeastOneNetTypeExists"
// oss
OssBucketNotFound = "NoSuchBucket"
OssBodyNotFound = "404 Not Found"
Expand Down
28 changes: 28 additions & 0 deletions alicloud/import_alicloud_db_account_privilege_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package alicloud

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAlicloudDBAccountPrivilege_import(t *testing.T) {
resourceName := "alicloud_db_account_privilege.privilege"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDBAccountPrivilege_basic,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
29 changes: 29 additions & 0 deletions alicloud/import_alicloud_db_account_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package alicloud

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAlicloudDBAccount_import(t *testing.T) {
resourceName := "alicloud_db_account.account"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDBAccount_basic,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"password"},
},
},
})
}
29 changes: 29 additions & 0 deletions alicloud/import_alicloud_db_backup_policy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package alicloud

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAlicloudDBBackupPolicy_import(t *testing.T) {
resourceName := "alicloud_db_backup_policy.policy"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDBBackupPolicy_basic,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"log_retention_period"},
},
},
})
}
28 changes: 28 additions & 0 deletions alicloud/import_alicloud_db_connection_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package alicloud

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAlicloudDBConnection_import(t *testing.T) {
resourceName := "alicloud_db_connection.foo"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDBConnection_basic,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
28 changes: 28 additions & 0 deletions alicloud/import_alicloud_db_database_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package alicloud

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAlicloudDBDatabase_import(t *testing.T) {
resourceName := "alicloud_db_database.db"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDBDatabase_basic,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Loading

0 comments on commit 8a69e75

Please sign in to comment.