How to set up region on terraform syntax for Alibaba Cloud?












2















From terraform official documentation :



Attributes Reference
The following attributes are exported in addition to the arguments
listed above:
regions - A list of regions. Each element contains the following
attributes:
id - ID of the region.
local_name - Name of the region in the local language.


And the syntax is like this :



value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


My first question is where can I get my local_name?



I think I cannot find it from alibaba cloud documentation



And second question is where to place the region id?



value = "${data.alicloud_regions.current_region_ds.regions.ap-southeast-5.mylocal_name}"


or



value = "${data.alicloud_regions.current_region_ds.regions.mylocal_name.ap-southeast-5}"









share|improve this question





























    2















    From terraform official documentation :



    Attributes Reference
    The following attributes are exported in addition to the arguments
    listed above:
    regions - A list of regions. Each element contains the following
    attributes:
    id - ID of the region.
    local_name - Name of the region in the local language.


    And the syntax is like this :



    value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


    My first question is where can I get my local_name?



    I think I cannot find it from alibaba cloud documentation



    And second question is where to place the region id?



    value = "${data.alicloud_regions.current_region_ds.regions.ap-southeast-5.mylocal_name}"


    or



    value = "${data.alicloud_regions.current_region_ds.regions.mylocal_name.ap-southeast-5}"









    share|improve this question



























      2












      2








      2








      From terraform official documentation :



      Attributes Reference
      The following attributes are exported in addition to the arguments
      listed above:
      regions - A list of regions. Each element contains the following
      attributes:
      id - ID of the region.
      local_name - Name of the region in the local language.


      And the syntax is like this :



      value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


      My first question is where can I get my local_name?



      I think I cannot find it from alibaba cloud documentation



      And second question is where to place the region id?



      value = "${data.alicloud_regions.current_region_ds.regions.ap-southeast-5.mylocal_name}"


      or



      value = "${data.alicloud_regions.current_region_ds.regions.mylocal_name.ap-southeast-5}"









      share|improve this question
















      From terraform official documentation :



      Attributes Reference
      The following attributes are exported in addition to the arguments
      listed above:
      regions - A list of regions. Each element contains the following
      attributes:
      id - ID of the region.
      local_name - Name of the region in the local language.


      And the syntax is like this :



      value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


      My first question is where can I get my local_name?



      I think I cannot find it from alibaba cloud documentation



      And second question is where to place the region id?



      value = "${data.alicloud_regions.current_region_ds.regions.ap-southeast-5.mylocal_name}"


      or



      value = "${data.alicloud_regions.current_region_ds.regions.mylocal_name.ap-southeast-5}"






      terraform alibaba-cloud






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 1 at 20:53









      marc_s

      581k13011211268




      581k13011211268










      asked Jan 1 at 19:57









      FoosomeFoosome

      285




      285
























          2 Answers
          2






          active

          oldest

          votes


















          1














          According to the Terraform documentation you should stick to Alibaba Cloud Regions ID.



          You don't necessarily need to provide the region ID itself. Take a look at a VPC Terraform sample where you enter just Availability Zone ID https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/examples/vpc/variables.tf



          variable "availability_zones" {
          default = "cn-beijing-c"
          }


          There are many other useful examples with code how to setup Alibaba Cloud resources.



          https://github.com/terraform-providers/terraform-provider-alicloud/tree/master/examples



          If you need more specific answer tell us what are you trying to achieve.






          share|improve this answer































            0














            You need to set up your region while you are configuring the AliCloud Provider itself.



            provider "alicloud" {
            access_key = "${var.accesskey}"
            secret_key = "${var.secretkey}"
            region = "${var.region}"
            }


            Note: There are several ways provided by Alicloud to enter credentials to authenticate. They are static and dynamic. Region ID must be listed out in credentials in order to authenticate using the static method, but if we are using dynamic method it can be sourced from the ALICLOUD_REGION environment variables.



            Now, To your Questions



            1) Initially, You specified the region in configuration. You will get the region you configured by following



            data "alicloud_regions" "current_region_ds" {
            current = true
            }

            output "current_region_id" {
            value = "${data.alicloud_regions.current_region_ds.regions.0.id}"
            }


            When you use current = true it will return the current region or else you have to define manually using name= region argument.



            value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


            It will give the id of the region specified. If you want to use local_name instead of id then change id to local_name.



            value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"


            Note: It is better to use id instead of local_name.



            2) Both ways you specified are wrong. You have specified the region in the configuration you are just accessing it.



            For instance,



            data "alicloud_regions" "current_region_ds" {
            name="cn-beijing"
            }


            then to access it,



            value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


            or



            value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"





            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53998512%2fhow-to-set-up-region-on-terraform-syntax-for-alibaba-cloud%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              According to the Terraform documentation you should stick to Alibaba Cloud Regions ID.



              You don't necessarily need to provide the region ID itself. Take a look at a VPC Terraform sample where you enter just Availability Zone ID https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/examples/vpc/variables.tf



              variable "availability_zones" {
              default = "cn-beijing-c"
              }


              There are many other useful examples with code how to setup Alibaba Cloud resources.



              https://github.com/terraform-providers/terraform-provider-alicloud/tree/master/examples



              If you need more specific answer tell us what are you trying to achieve.






              share|improve this answer




























                1














                According to the Terraform documentation you should stick to Alibaba Cloud Regions ID.



                You don't necessarily need to provide the region ID itself. Take a look at a VPC Terraform sample where you enter just Availability Zone ID https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/examples/vpc/variables.tf



                variable "availability_zones" {
                default = "cn-beijing-c"
                }


                There are many other useful examples with code how to setup Alibaba Cloud resources.



                https://github.com/terraform-providers/terraform-provider-alicloud/tree/master/examples



                If you need more specific answer tell us what are you trying to achieve.






                share|improve this answer


























                  1












                  1








                  1







                  According to the Terraform documentation you should stick to Alibaba Cloud Regions ID.



                  You don't necessarily need to provide the region ID itself. Take a look at a VPC Terraform sample where you enter just Availability Zone ID https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/examples/vpc/variables.tf



                  variable "availability_zones" {
                  default = "cn-beijing-c"
                  }


                  There are many other useful examples with code how to setup Alibaba Cloud resources.



                  https://github.com/terraform-providers/terraform-provider-alicloud/tree/master/examples



                  If you need more specific answer tell us what are you trying to achieve.






                  share|improve this answer













                  According to the Terraform documentation you should stick to Alibaba Cloud Regions ID.



                  You don't necessarily need to provide the region ID itself. Take a look at a VPC Terraform sample where you enter just Availability Zone ID https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/examples/vpc/variables.tf



                  variable "availability_zones" {
                  default = "cn-beijing-c"
                  }


                  There are many other useful examples with code how to setup Alibaba Cloud resources.



                  https://github.com/terraform-providers/terraform-provider-alicloud/tree/master/examples



                  If you need more specific answer tell us what are you trying to achieve.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 1 at 21:13









                  wojciehwojcieh

                  1678




                  1678

























                      0














                      You need to set up your region while you are configuring the AliCloud Provider itself.



                      provider "alicloud" {
                      access_key = "${var.accesskey}"
                      secret_key = "${var.secretkey}"
                      region = "${var.region}"
                      }


                      Note: There are several ways provided by Alicloud to enter credentials to authenticate. They are static and dynamic. Region ID must be listed out in credentials in order to authenticate using the static method, but if we are using dynamic method it can be sourced from the ALICLOUD_REGION environment variables.



                      Now, To your Questions



                      1) Initially, You specified the region in configuration. You will get the region you configured by following



                      data "alicloud_regions" "current_region_ds" {
                      current = true
                      }

                      output "current_region_id" {
                      value = "${data.alicloud_regions.current_region_ds.regions.0.id}"
                      }


                      When you use current = true it will return the current region or else you have to define manually using name= region argument.



                      value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                      It will give the id of the region specified. If you want to use local_name instead of id then change id to local_name.



                      value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"


                      Note: It is better to use id instead of local_name.



                      2) Both ways you specified are wrong. You have specified the region in the configuration you are just accessing it.



                      For instance,



                      data "alicloud_regions" "current_region_ds" {
                      name="cn-beijing"
                      }


                      then to access it,



                      value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                      or



                      value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"





                      share|improve this answer




























                        0














                        You need to set up your region while you are configuring the AliCloud Provider itself.



                        provider "alicloud" {
                        access_key = "${var.accesskey}"
                        secret_key = "${var.secretkey}"
                        region = "${var.region}"
                        }


                        Note: There are several ways provided by Alicloud to enter credentials to authenticate. They are static and dynamic. Region ID must be listed out in credentials in order to authenticate using the static method, but if we are using dynamic method it can be sourced from the ALICLOUD_REGION environment variables.



                        Now, To your Questions



                        1) Initially, You specified the region in configuration. You will get the region you configured by following



                        data "alicloud_regions" "current_region_ds" {
                        current = true
                        }

                        output "current_region_id" {
                        value = "${data.alicloud_regions.current_region_ds.regions.0.id}"
                        }


                        When you use current = true it will return the current region or else you have to define manually using name= region argument.



                        value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                        It will give the id of the region specified. If you want to use local_name instead of id then change id to local_name.



                        value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"


                        Note: It is better to use id instead of local_name.



                        2) Both ways you specified are wrong. You have specified the region in the configuration you are just accessing it.



                        For instance,



                        data "alicloud_regions" "current_region_ds" {
                        name="cn-beijing"
                        }


                        then to access it,



                        value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                        or



                        value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"





                        share|improve this answer


























                          0












                          0








                          0







                          You need to set up your region while you are configuring the AliCloud Provider itself.



                          provider "alicloud" {
                          access_key = "${var.accesskey}"
                          secret_key = "${var.secretkey}"
                          region = "${var.region}"
                          }


                          Note: There are several ways provided by Alicloud to enter credentials to authenticate. They are static and dynamic. Region ID must be listed out in credentials in order to authenticate using the static method, but if we are using dynamic method it can be sourced from the ALICLOUD_REGION environment variables.



                          Now, To your Questions



                          1) Initially, You specified the region in configuration. You will get the region you configured by following



                          data "alicloud_regions" "current_region_ds" {
                          current = true
                          }

                          output "current_region_id" {
                          value = "${data.alicloud_regions.current_region_ds.regions.0.id}"
                          }


                          When you use current = true it will return the current region or else you have to define manually using name= region argument.



                          value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                          It will give the id of the region specified. If you want to use local_name instead of id then change id to local_name.



                          value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"


                          Note: It is better to use id instead of local_name.



                          2) Both ways you specified are wrong. You have specified the region in the configuration you are just accessing it.



                          For instance,



                          data "alicloud_regions" "current_region_ds" {
                          name="cn-beijing"
                          }


                          then to access it,



                          value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                          or



                          value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"





                          share|improve this answer













                          You need to set up your region while you are configuring the AliCloud Provider itself.



                          provider "alicloud" {
                          access_key = "${var.accesskey}"
                          secret_key = "${var.secretkey}"
                          region = "${var.region}"
                          }


                          Note: There are several ways provided by Alicloud to enter credentials to authenticate. They are static and dynamic. Region ID must be listed out in credentials in order to authenticate using the static method, but if we are using dynamic method it can be sourced from the ALICLOUD_REGION environment variables.



                          Now, To your Questions



                          1) Initially, You specified the region in configuration. You will get the region you configured by following



                          data "alicloud_regions" "current_region_ds" {
                          current = true
                          }

                          output "current_region_id" {
                          value = "${data.alicloud_regions.current_region_ds.regions.0.id}"
                          }


                          When you use current = true it will return the current region or else you have to define manually using name= region argument.



                          value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                          It will give the id of the region specified. If you want to use local_name instead of id then change id to local_name.



                          value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"


                          Note: It is better to use id instead of local_name.



                          2) Both ways you specified are wrong. You have specified the region in the configuration you are just accessing it.



                          For instance,



                          data "alicloud_regions" "current_region_ds" {
                          name="cn-beijing"
                          }


                          then to access it,



                          value = "${data.alicloud_regions.current_region_ds.regions.0.id}"


                          or



                          value = "${data.alicloud_regions.current_region_ds.regions.0.local_name}"






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 26 at 6:08









                          Ranjith UdayakumarRanjith Udayakumar

                          346




                          346






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53998512%2fhow-to-set-up-region-on-terraform-syntax-for-alibaba-cloud%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              MongoDB - Not Authorized To Execute Command

                              How to fix TextFormField cause rebuild widget in Flutter

                              in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith