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

Auto-generate BgpPeer #2434

Merged
merged 16 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
4 changes: 4 additions & 0 deletions products/compute/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ datasources: !ruby/object:Overrides::ResourceOverrides
exclude: true
ResourcePolicy: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RouterBgpPeer: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RouterNat: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
ExternalVpnGateway: !ruby/object:Overrides::Ansible::ResourceOverride
Expand Down Expand Up @@ -330,6 +332,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
exclude: true
RegionUrlMap: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RouterBgpPeer: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RouterNat: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
Zone: !ruby/object:Overrides::Ansible::ResourceOverride
Expand Down
170 changes: 170 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9332,6 +9332,176 @@ objects:
- :ERRORS_ONLY
- :TRANSLATIONS_ONLY
- :ALL
- !ruby/object:Api::Resource
name: 'RouterBgpPeer'
base_url: projects/{{project}}/regions/{{region}}/routers/{{router}}
self_link: projects/{{project}}/regions/{{region}}/routers/{{router}}
create_verb: :PATCH
update_verb: :PATCH
delete_verb: :PATCH
identity:
- name
nested_query: !ruby/object:Api::Resource::NestedQuery
modify_by_patch: true
keys:
- bgpPeers
description: |
BGP information that must be configured into the routing stack to
establish BGP peering. This information must specify the peer ASN
and either the interface name, IP address, or peer IP address.
Please refer to RFC4273.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Google Cloud Router': 'https://cloud.google.com/router/docs/'
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/routers'
async: !ruby/object:Api::Async
operation: !ruby/object:Api::Async::Operation
kind: 'compute#operation'
path: 'name'
base_url: 'projects/{{project}}/regions/{{regions}}/operations/{{op_id}}'
wait_ms: 1000
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 10
update_minutes: 10
delete_minutes: 10
result: !ruby/object:Api::Async::Result
path: 'targetLink'
status: !ruby/object:Api::Async::Status
path: 'status'
complete: 'DONE'
allowed:
- 'PENDING'
- 'RUNNING'
- 'DONE'
error: !ruby/object:Api::Async::Error
path: 'error/errors'
message: 'message'
parameters:
- !ruby/object:Api::Type::ResourceRef
name: 'router'
resource: 'Router'
imports: 'name'
description: |
The name of the Cloud Router in which this BgpPeer will be configured.
required: true
input: true
url_param_only: true
- !ruby/object:Api::Type::ResourceRef
name: region
resource: Region
imports: name
description: Region where the router and BgpPeer reside.
input: true
required: true
url_param_only: true
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
Name of this BGP peer. The name must be 1-63 characters long,
and comply with RFC1035. Specifically, the name must be 1-63 characters
long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which
means the first character must be a lowercase letter, and all
following characters must be a dash, lowercase letter, or digit,
except the last character, which cannot be a dash.
required: true
input: true
- !ruby/object:Api::Type::String
name: 'interfaceName'
description: |
Name of the interface the BGP peer is associated with.
required: true
input: true
- !ruby/object:Api::Type::String
name: 'ipAddress'
description: |
IP address of the interface inside Google Cloud Platform.
Only IPv4 is supported.
output: true
- !ruby/object:Api::Type::String
name: 'peerIpAddress'
description: |
IP address of the BGP interface outside Google Cloud Platform.
Only IPv4 is supported.
required: true
drebes marked this conversation as resolved.
Show resolved Hide resolved
input: true
- !ruby/object:Api::Type::Integer
name: 'peerAsn'
description: |
Peer BGP Autonomous System Number (ASN).
Each BGP interface may use a different value.
required: true
input: true
- !ruby/object:Api::Type::Integer
name: 'advertisedRoutePriority'
description: |
The priority of routes advertised to this BGP peer.
Where there is more than one matching route of maximum
length, the routes with the lowest priority value win.
- !ruby/object:Api::Type::Enum
name: advertiseMode
description: |
User-specified flag to indicate which mode to use for advertisement.
Valid values of this enum field are: `DEFAULT`, `CUSTOM`
values:
- :DEFAULT
- :CUSTOM
default_value: :DEFAULT
input: true
- !ruby/object:Api::Type::Array
name: advertisedGroups
description: |
User-specified list of prefix groups to advertise in custom
mode, which can take one of the following options:

* `ALL_SUBNETS`: Advertises all available subnets, including peer VPC subnets.
* `ALL_VPC_SUBNETS`: Advertises the router's own VPC subnets.
* `ALL_PEER_VPC_SUBNETS`: Advertises peer subnets of the router's VPC network.


Note that this field can only be populated if advertiseMode is `CUSTOM`
and overrides the list defined for the router (in the "bgp" message).
These groups are advertised in addition to any specified prefixes.
Leave this field blank to advertise no custom groups.
send_empty_value: true
item_type: Api::Type::String
input: true
- !ruby/object:Api::Type::Array
name: advertisedIpRanges
description: |
User-specified list of individual IP ranges to advertise in
custom mode. This field can only be populated if advertiseMode
is `CUSTOM` and is advertised to all peers of the router. These IP
ranges will be advertised in addition to any specified groups.
Leave this field blank to advertise no custom IP ranges.
send_empty_value: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: range
drebes marked this conversation as resolved.
Show resolved Hide resolved
required: true
description: |
The IP range to advertise. The value must be a
CIDR-formatted string.
- !ruby/object:Api::Type::String
name: description
description: |
User-specified description for the IP range.
send_empty_value: true
- !ruby/object:Api::Type::String
name: 'managementType'
description: |
The resource that configures and manages this BGP peer.

* `MANAGED_BY_USER` is the default value and can be managed by
you or other users
* `MANAGED_BY_ATTACHMENT` is a BGP peer that is configured and
managed by Cloud Interconnect, specifically by an
InterconnectAttachment of type PARTNER. Google automatically
creates, updates, and deletes this type of BGP peer when the
PARTNER InterconnectAttachment is created, updated,
or deleted.
output: true
- !ruby/object:Api::Resource
name: 'Snapshot'
kind: 'compute#snapshot'
Expand Down
2 changes: 2 additions & 0 deletions products/compute/inspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
exclude: true
ResourcePolicy: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
RouterBgpPeer: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
Subnetwork: !ruby/object:Overrides::Inspec::ResourceOverride
exclude_resource: true
iam_policy: !ruby/object:Api::Resource::IamPolicy
Expand Down
30 changes: 30 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,36 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_code: !ruby/object:Provider::Terraform::CustomCode
constants: 'templates/terraform/constants/router_nat.go.erb'
resource_definition: 'templates/terraform/resource_definition/router_nat.go.erb'
RouterBgpPeer: !ruby/object:Overrides::Terraform::ResourceOverride
legacy_name: 'google_compute_router_peer'
exclude_validator: true
id_format: "projects/{{project}}/regions/{{region}}/routers/{{router}}/{{name}}"
mutex: router/{{region}}/{{router}}
examples:
# These examples are not used to autogenerate tests, as fine-grained
drebes marked this conversation as resolved.
Show resolved Hide resolved
# resources do not fit the normal test flow - we need to test deletion
# in a test step while parent resource still exists vs in CheckDestroy
# when all resources have been deleted.
- !ruby/object:Provider::Terraform::Examples
name: "router_peer_basic"
primary_resource_id: "peer"
skip_test: true
vars:
router_name: "my-router"
peer_name: "my-router-peer"
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validateRFC1035Name(2, 63)'
interfaceName: !ruby/object:Overrides::Terraform::PropertyOverride
name: 'interface'
region: !ruby/object:Overrides::Terraform::PropertyOverride
drebes marked this conversation as resolved.
Show resolved Hide resolved
required: false
default_from_api: true
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
description: |
{{description}}
If it is not provided, the provider region is used.
Snapshot: !ruby/object:Overrides::Terraform::ResourceOverride
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 5
Expand Down
9 changes: 9 additions & 0 deletions templates/terraform/examples/router_peer_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "google_compute_router_peer" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['peer_name'] %>"
router = "<%= ctx[:vars]['router_name'] %>"
region = "us-central1"
peer_ip_address = "169.254.1.2"
peer_asn = 65513
advertised_route_priority = 100
interface = "interface-1"
}
Loading