Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Remove agent_script data source to simplify resources#8

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 1 commit intomainfromtidyagentscript
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
7 changes: 7 additions & 0 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
default: testacc

fmt:
terraform fmt -recursive

gen:
# go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
tfplugindocs

# Run acceptance tests
.PHONY: testacc
testacc:
Expand Down
47 changes: 0 additions & 47 deletionsdocs/data-sources/agent_script.md
View file
Open in desktop

This file was deleted.

9 changes: 5 additions & 4 deletionsdocs/data-sources/workspace.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,12 +26,13 @@ resource "kubernetes_pod" "dev" {

### Optional

-**id** (String) The ID of this resource.
-`id` (String) The ID of this resource.

### Read-Only

- **name** (String) Name of the workspace.
- **owner** (String) Username of the workspace owner.
- **transition** (String) Either "start" or "stop". Use this to start/stop resources with "count".
- `name` (String) Name of the workspace.
- `owner` (String) Username of the workspace owner.
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
- `transition` (String) Either "start" or "stop". Use this to start/stop resources with "count".


35 changes: 10 additions & 25 deletionsdocs/index.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,10 +13,6 @@ description: |-
## Example

```terraform
variable "gcp_credentials" {
sensitive = true
}

terraform {
required_providers {
coder = {
Expand All@@ -26,26 +22,23 @@ terraform {
}

provider "google" {
region = "us-central1"
credentials = var.gcp_credentials
region = "us-central1"
}

data "coder_workspace" "me" {}
data "google_compute_default_service_account" "default" {}
data "coder_agent_script" "dev" {

resource "coder_agent" "dev" {
arch = "amd64"
os = "linux"
}
resource "random_string" "random" {
count = data.coder_workspace.me.transition == "start" ? 1 : 0
length = 8
special = false
auth = "google-instance-identity"
}

data "google_compute_default_service_account" "default" {}

resource "google_compute_instance" "dev" {
zone = "us-central1-a"
count = data.coder_workspace.me.transition == "start" ? 1 : 0
name = "coder-${lower(random_string.random[0].result)}"
count = data.coder_workspace.me.start_count
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
machine_type = "e2-medium"
network_interface {
network = "default"
Expand All@@ -62,15 +55,7 @@ resource "google_compute_instance" "dev" {
email = data.google_compute_default_service_account.default.email
scopes = ["cloud-platform"]
}
metadata_startup_script = data.coder_agent_script.dev.value
}

resource "coder_agent" "dev" {
count = length(google_compute_instance.dev)
auth {
type = "google-instance-identity"
instance_id = google_compute_instance.dev[0].instance_id
}
metadata_startup_script = coder_agent.dev.init_script
}
```

Expand All@@ -79,4 +64,4 @@ resource "coder_agent" "dev" {

### Optional

-**url** (String) The URL to access Coder.
-`url` (String) The URL to access Coder.
28 changes: 17 additions & 11 deletionsdocs/resources/agent.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,19 +13,19 @@ Use this resource to associate an agent.
## Example Usage

```terraform
data "coder_agent_script" "dev" {
os = "linux"
arch = "amd64"
data "coder_workspace" "me" {
}

resource "coder_agent" "dev" {
startup_script = "code-server"
os = "linux"
arch = "amd64"
}

resource "google_compute_instance" "dev" {
resource "kubernetes_pod" "dev" {
count = data.coder_workspace.me.start_count
spec {
container {
command = ["sh", "-c",data.coder_agent_script.dev.value]
command = ["sh", "-c",coder_agent.dev.init_script]
env {
name = "CODER_TOKEN"
value = coder_agent.dev.token
Expand All@@ -38,15 +38,21 @@ resource "google_compute_instance" "dev" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `arch` (String) The architecture the agent will run on. Must be one of: "amd64", "arm64".
- `os` (String) The operating system the agent will run on. Must be one of: "linux", "darwin", or "windows".

### Optional

-**env** (Map ofString)A mapping of environment variables to set inside the workspace.
-**id** (String)The ID ofthis resource.
-**instance_id** (String)An instanceIDfrom a provisioned instance to enable zero-trust agent authentication.
-**startup_script** (String) A script to run after the agent starts.
-`auth` (String)The authentication type the agent will use. Must be one of: "token", "google-instance-identity", "aws-instance-identity", "azure-instance-identity".
-`env` (Map ofString)A mapping ofenvironment variables to set inside the workspace.
-`id` (String)TheIDof this resource.
-`startup_script` (String) A script to run after the agent starts.

### Read-Only

- **token** (String) Set the environment variable "CODER_TOKEN" with this token to authenticate an agent.
- `init_script` (String) Run this script on startup of an instance to initialize the agent.
- `token` (String) Set the environment variable "CODER_TOKEN" with this token to authenticate an agent.


44 changes: 44 additions & 0 deletionsdocs/resources/agent_instance.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "coder_agent_instance Resource - terraform-provider-coder"
subcategory: ""
description: |-
Use this resource to associate an instance ID with an agent for zero-trust authentication. This association is done automatically for "googlecomputeinstance", "awsinstance", "azurermlinuxvirtualmachine", and "azurermwindowsvirtual_machine" resources.
---

# coder_agent_instance (Resource)

Use this resource to associate an instance ID with an agent for zero-trust authentication. This association is done automatically for "google_compute_instance", "aws_instance", "azurerm_linux_virtual_machine", and "azurerm_windows_virtual_machine" resources.

## Example Usage

```terraform
resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
auth = "google-instance-identity"
}

resource "google_compute_instance" "dev" {
zone = "us-central1-a"
}

resource "coder_agent_instance" "dev" {
agent_id = coder_agent.dev.id
instance_id = google_compute_instance.dev.instance_id
}
```

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

### Required

- `agent_id` (String) The "id" property of a "coder_agent" resource to associate with.
- `instance_id` (String) The instance identifier of a provisioned resource.

### Optional

- `id` (String) The ID of this resource.


12 changes: 0 additions & 12 deletionsexamples/data-sources/coder_agent_script/data-source.tf
View file
Open in desktop

This file was deleted.

33 changes: 9 additions & 24 deletionsexamples/provider/provider.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
variable "gcp_credentials" {
sensitive = true
}

terraform {
required_providers {
coder = {
Expand All@@ -11,26 +7,23 @@ terraform {
}

provider "google" {
region = "us-central1"
credentials = var.gcp_credentials
region = "us-central1"
}

data "coder_workspace" "me" {}
data "google_compute_default_service_account" "default" {}
data "coder_agent_script" "dev" {

resource "coder_agent" "dev" {
arch = "amd64"
os = "linux"
}
resource "random_string" "random" {
count = data.coder_workspace.me.transition == "start" ? 1 : 0
length = 8
special = false
auth = "google-instance-identity"
}

data "google_compute_default_service_account" "default" {}

resource "google_compute_instance" "dev" {
zone = "us-central1-a"
count = data.coder_workspace.me.transition == "start" ? 1 : 0
name = "coder-${lower(random_string.random[0].result)}"
count = data.coder_workspace.me.start_count
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
machine_type = "e2-medium"
network_interface {
network = "default"
Expand All@@ -47,13 +40,5 @@ resource "google_compute_instance" "dev" {
email = data.google_compute_default_service_account.default.email
scopes = ["cloud-platform"]
}
metadata_startup_script = data.coder_agent_script.dev.value
}

resource "coder_agent" "dev" {
count = length(google_compute_instance.dev)
auth {
type = "google-instance-identity"
instance_id = google_compute_instance.dev[0].instance_id
}
metadata_startup_script = coder_agent.dev.init_script
}
12 changes: 6 additions & 6 deletionsexamples/resources/coder_agent/resource.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
data "coder_agent_script" "dev" {
os = "linux"
arch = "amd64"
data "coder_workspace" "me" {
}

resource "coder_agent" "dev" {
startup_script = "code-server"
os = "linux"
arch = "amd64"
}

resource "google_compute_instance" "dev" {
resource "kubernetes_pod" "dev" {
count = data.coder_workspace.me.start_count
spec {
container {
command = ["sh", "-c",data.coder_agent_script.dev.value]
command = ["sh", "-c",coder_agent.dev.init_script]
env {
name = "CODER_TOKEN"
value = coder_agent.dev.token
Expand Down
14 changes: 14 additions & 0 deletionsexamples/resources/coder_agent_instance/resource.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
auth = "google-instance-identity"
}

resource "google_compute_instance" "dev" {
zone = "us-central1-a"
}

resource "coder_agent_instance" "dev" {
agent_id = coder_agent.dev.id
instance_id = google_compute_instance.dev.instance_id
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp