I have tried to create GCP VPC and multiple subnet...
# google-cloud
h
I have tried to create GCP VPC and multiple subnets but i see vpc names and subnet names are appending with hashes...is there anyway i can fix it.
can access my code here: https://pastebin.com/2PmnPtNF
and this is my
Pulumi.stack.yaml
file
Copy code
bkraju-gcp-network:subnets:
  - name: bksg-infraplay-subnet1
    primary_ip_cidr: 10.187.16.0/24
    secondary_ip_cidrs:
    - range: 172.23.0.0/19
      name: bksg-infraplay-secondary1
  - name: bksg-infraplay-subnet2
    primary_ip_cidr: 10.187.17.0/24
    secondary_ip_cidrs:
    - range: 172.25.0.0/19
      name: bksg-infraplay-secondary2
    - range: 172.24.0.0/19
      name: bksg-infraplay-secondary3
  bk-gcp-network:vpc_name: bkinfra-playground-vpc
  gcp:project: learngcp-316009
  gcp:region: asia-southeast1
t
p
Just as Mikhail wrote, you would need to explicitly name the subnets to disable Pulumi auto-naming:
Copy code
self.subnet = compute.Subnetwork(subnet['name'],
===>                                        name=subnet['name'],
                                            network=self.network.self_link,
                                            ip_cidr_range=subnet['primary_ip_cidr'],
                                            private_ip_google_access=True,
                                            secondary_ip_ranges=parsed_ranges,
                                            opts=ResourceOptions(parent=self.network)
                                            )
Although, if it’s not a hard requirements for you, I’d leave the auto-naming enabled.
h
Thank you @tall-librarian-49374 and @prehistoric-activity-61023 for your help 🙂
And @prehistoric-activity-61023 for vpc it worked like this.
Copy code
self.network = compute.Network(args.vpc_name,
                                       name=args.vpc_name,
                                       auto_create_subnetworks=False,
                                       opts=ResourceOptions(parent=self)