这是indexloc提供的服务,不要输入任何密码
Skip to content

Flesh out secure_compute_network data source #325

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
62 changes: 62 additions & 0 deletions client/secure_compute_network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package client

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-log/tflog"
)

// SecureComputeNetworkAWS represents the AWS configuration part of a Secure Compute Network.
type SecureComputeNetworkAWS struct {
AccountID string `json:"AccountId"`
Region string `json:"Region"`
ElasticIpAddresses []string `json:"ElasticIpAddresses,omitempty"`
LambdaRoleArn *string `json:"LambdaRoleArn,omitempty"`
SecurityGroupId *string `json:"SecurityGroupId,omitempty"`
StackId *string `json:"StackId,omitempty"`
SubnetIds []string `json:"SubnetIds,omitempty"`
SubscriptionArn *string `json:"SubscriptionArn,omitempty"`
VpcId *string `json:"VpcId,omitempty"`
}

// SecureComputeNetwork represents a Vercel Secure Compute Network configuration.
type SecureComputeNetwork struct {
DC string `json:"dc"`
ProjectIDs []string `json:"projectIds,omitempty"`
ProjectsCount *int `json:"projectsCount,omitempty"`
PeeringConnectionsCount *int `json:"peeringConnectionsCount,omitempty"`

AWS SecureComputeNetworkAWS `json:"AWS"`
ConfigurationName string `json:"ConfigurationName"`
ID string `json:"Id"`
TeamID string `json:"TeamId"`
CIDRBlock *string `json:"CidrBlock,omitempty"`
AvailabilityZoneIDs []string `json:"AvailabilityZoneIds,omitempty"`
Version string `json:"Version"`
ConfigurationStatus string `json:"ConfigurationStatus"`
}

// ListSecureComputeNetworks fetches all Secure Compute Networks for a team.
func (c *Client) ListSecureComputeNetworks(
ctx context.Context,
teamID string,
) ([]SecureComputeNetwork, error) {
url := fmt.Sprintf("%s/v1/connect/configurations", c.baseURL)
if c.TeamID(teamID) != "" {
url = fmt.Sprintf("%s?teamId=%s", url, c.TeamID(teamID))
}
tflog.Info(ctx, "reading secure compute networks", map[string]any{
"url": url,
"team_id": c.TeamID(teamID),
})

var networks []SecureComputeNetwork
err := c.doRequest(clientRequest{
ctx: ctx,
method: "GET",
url: url,
}, &networks)

return networks, err
}
55 changes: 55 additions & 0 deletions docs/data-sources/secure_compute_network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "vercel_secure_compute_network Data Source - terraform-provider-vercel"
subcategory: ""
description: |-
Provides information about an existing Vercel Secure Compute Network.
This data source allows you to retrieve details about a Secure Compute Network by its name and optional team ID.
---

# vercel_secure_compute_network (Data Source)

Provides information about an existing Vercel Secure Compute Network.

This data source allows you to retrieve details about a Secure Compute Network by its name and optional team ID.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the Secure Compute Network configuration.

### Optional

- `team_id` (String) The ID of the Vercel team the Secure Compute Network belongs to. If omitted, the provider will use the team configured on the provider or the user's default team.

### Read-Only

- `availability_zone_ids` (Set of String) A set of AWS Availability Zone IDs where the Secure Compute Network resources are deployed.
- `aws` (Attributes) AWS configuration for the Secure Compute Network. (see [below for nested schema](#nestedatt--aws))
- `cidr_block` (String) The CIDR block assigned to the Secure Compute Network.
- `configuration_status` (String) The operational status of the Secure Compute Network (e.g., 'ready', 'create_in_progress').
- `dc` (String) The data center (region) associated with the Secure Compute Network.
- `id` (String) The unique identifier of the Secure Compute Network.
- `peering_connections_count` (Number) The number of peering connections established for this Secure Compute Network.
- `project_ids` (Set of String) A list of Vercel Project IDs connected to this Secure Compute Network.
- `projects_count` (Number) The number of Vercel Projects connected to this Secure Compute Network.
- `version` (String) The current version identifier of the Secure Compute Network configuration.

<a id="nestedatt--aws"></a>
### Nested Schema for `aws`

Read-Only:

- `account_id` (String) The AWS account ID.
- `elastic_ip_addresses` (Set of String) A list of Elastic IP addresses.
- `lambda_role_arn` (String) The ARN of the Lambda role.
- `region` (String) The AWS region.
- `security_group_id` (String) The ID of the security group.
- `stack_id` (String) The ID of the CloudFormation stack.
- `subnet_ids` (Set of String) A list of subnet IDs.
- `subscription_arn` (String) The ARN of the subscription.
- `vpc_id` (String) The ID of the VPC.
10 changes: 0 additions & 10 deletions vercel/contains.go

This file was deleted.

29 changes: 29 additions & 0 deletions vercel/convert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package vercel

import (
"context"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
)

func intPtrToInt64Ptr(i *int) *int64 {
if i == nil {
return nil
}
val := int64(*i)
return &val
}

func stringsToSet(ctx context.Context, strings []string) (types.Set, diag.Diagnostics) {
diags := diag.Diagnostics{}
stringSet := []attr.Value{}
for _, s := range strings {
stringSet = append(stringSet, types.StringValue(s))
}

set, d := types.SetValueFrom(ctx, types.StringType, stringSet)
diags.Append(d...)
return set, diags
}
Loading