Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alicloud provider, including resource and examples of alicloud provider #10761

Closed
wants to merge 10 commits into from

Conversation

xiaozhu36
Copy link
Contributor

This is terraform alicloud provider provided by Official AliCloud. The provider is aim at building, changing, and managing alicloud infrastructure safely and efficiently based on terraform powerful management capabilities for infrastructure. At present, it has supported several alicloud resource, such as ECS, VPC, SLB, Security Group and EIP. With the continuous development and improvement to the provider, it will have more perfect function and support more alicloud resource. We hope the PR to integrate alicloud provider into terraform and help consumer to manage alicloud infrastructure. If you have any question, we are glad to get feedback as soon as possible, thanks a lot.

Copy link
Contributor

@stack72 stack72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xiaozhu36

thanks for the work here - I have left a lot of comments - mostly stylistic inline

The most comment is that we are using d.SetPartial in Create funcs and we don't need to

The second is that every time we have a d.HasChange in the Updatefunc, we have an update call - can these not be batched up? I.e. if a security group has a name and a description change, does it need to be 2 update commands or just 1?

Apart from that, it is looking good. You will need to govendor the github.com/denverdino/aliyungo/common as that is causing build errors

Thanks

Paul

//Modify with your Access Key Id and Access Key Secret

const (
TestAccessKeyId = "****"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should hard code these - we should use environment variables to pass these in - this is a standard practice across providers

TestInstanceId = "MY_TEST_INSTANCE_ID"
TestSecurityGroupId = "MY_TEST_SECURITY_GROUP_ID"
TestImageId = "MY_TEST_IMAGE_ID"
TestAccountId = "MY_TEST_ACCOUNT_ID" //Get from https://account.console.aliyun.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again this should not be hard coded

}

func testAccPreCheck(t *testing.T) {
if v := os.Getenv("ALICLOUD_PROFILE"); v == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is ALICLOUD_PROFILE? That's not mentioned in the provider.go

d.SetId(diskID)
d.Partial(true)

d.SetPartial("name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to SetPartial here for any values


log.Printf("[DEBUG] DescribeDiskAttribute for instance: %#v", disks)

if disks != nil && len(disks) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would handle this slightly differenly -

if disks == nil || len(disks) == 0 {
  return fmt.Errorf("No disks found")
}

That way you don't have to wrap the d.Set in the if statement

},

"bandwidth_packages": &schema.Schema{
Type: schema.TypeList,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see only 4 bandwidth_packages are allowed, we can add:

MaxItems: 4 to the schema

We can then remove the if len() > 4 check below

if v, ok := d.GetOk("name"); ok {
name = v.(string)
}
// } else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed or is it a todo?

d.SetPartial("spec")
d.SetPartial("vpc_id")

// for i, packageId := range resp.BandwidthPackageIds.BandwidthPackageId {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant comment?

}

d.SetId(resp.NatGatewayId)
d.Partial(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need d.Partial in Create

spec = NatGatewaySmallSpec
}

args := &ModifyNatGatewaySpecArgs{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the pattern of a single conn.ModifyNatGatewaySpec and pass the args in

@xiaozhu36
Copy link
Contributor Author

Hi @stack72

Thanks very much for your help and review advise, and our team have improve existing defects in my provider as per your advise.

Now, we want to pull a new request and the PR has the following changes:

  1. Improved the existing defects and fixed some bugs, including removing d.SetPartial in the Create funcs, improving Updatefunc, adding some attributes for the some parameters and so on.

  2. Using govendor added the SDK correctly and updated the dependencies.

  3. Ran commands 'make fmt' and 'make test vet', and passed it successfully.

Please review them and looking forward to a good news. Thanks very much.

Thanks

Guimin He

@stack72
Copy link
Contributor

stack72 commented Jan 18, 2017

Closed via #11235

@stack72 stack72 closed this Jan 18, 2017
@ghost
Copy link

ghost commented Apr 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants