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

Remove obsolete documentation #342

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
79 changes: 2 additions & 77 deletions docs/vendors/terraform/terraform-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ What would you say if you could manage Spacelift resources - that is [stacks](..

Our Terraform provider is open source and its [README](https://github.com/spacelift-io/terraform-provider-spacelift) always contains the latest available documentation. It's also distributed as part of our [Docker runner image](../../integrations/docker.md#standard-runner-image) and available through our [own provider registry](terraform-provider.md#how-it-works). The purpose of this article isn't as much to document the provider itself but to show how it can be used to incorporate Spacelift resources into your infra-as-code.

So, without further ado, let's define a stack:
An example of a Spacelift stack being defined through Terraform:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, this sentence comes across as a bit abrupt. The advantage of the "So, without further ado, ..." part was that it connected the example to the previous piece of text.

If you're going to reword it, I think it would need to be something like: "Here is an example showing how to define a Spacelift stack using Terraform".


```terraform title="stack.tf"
resource "spacelift_stack" "managed-stack" {
Expand All @@ -18,82 +18,7 @@ resource "spacelift_stack" "managed-stack" {
}
```

That's awesome. But can we put Terraform to good use and integrate it with resources from a completely different provider? Sure we can, and we have a good excuse, too. Stacks accessibility can be managed [by GitHub teams](../../concepts/stack/README.md#access-readers-and-writers-teams), so why don't we define some?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to replace this with an up-to-date example instead of deleting it?

Without this, the "Taking it for a spin" section is underwhelming. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we point to the terraform starter guide on GitHub?
I think that's the only hands-on terraform guide that we have that guides you through using the Spacelift provider.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I hate duplicating content. 👍


```terraform title="stack-and-teams.tf"
resource "github_team" "stack-readers" {
name = "managed-stack-readers"
}

resource "github_team" "stack-writers" {
name = "managed-stack-writers"
}

resource "spacelift_stack" "managed-stack" {
name = "Stack managed by Spacelift"

# Source code.
repository = "testing-spacelift"
branch = "master"

# Access.
readers_team = github_team.stack_readers.slug
writers_team = github_team.stack_writers.slug
}
```

Now that we programmatically combine Spacelift and GitHub resources, let's add AWS to the mix and give our new stack a dedicated [IAM role](../../integrations/cloud-providers/aws.md):

```terraform title="stack-teams-and-iam.tf"
resource "github_team" "stack-readers" {
name = "managed-stack-readers"
}

resource "github_team" "stack-writers" {
name = "managed-stack-writers"
}

resource "spacelift_stack" "managed-stack" {
name = "Stack managed by Spacelift"

# Source code.
repository = "testing-spacelift"
branch = "master"

# Access.
readers_team = github_team.stack_readers.slug
writers_team = github_team.stack_writers.slug
}

# IAM role.
resource "aws_iam_role" "managed-stack" {
name = "spacelift-managed-stack"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
jsondecode(
spacelift_stack.managed-stack.aws_assume_role_policy_statement
)
]
})
}

# Attaching a nice, powerful policy to it.
resource "aws_iam_role_policy_attachment" "managed-stack" {
role = aws_iam_role.managed-stack.name
policy_arn = "arn:aws:iam::aws:policy/PowerUserAccess"
}

# Telling Spacelift stack to assume it.
resource "spacelift_stack_aws_role" "managed-stack" {
stack_id = spacelift_stack.managed-stack.id
role_arn = aws_iam_role.managed-stack.arn
}
```

!!! success
OK, so who wants to go back to clicking on things in the web GUI? Because you will likely need to do some clicking, too, [at least with your first stack](terraform-provider.md#proposed-workflow).
A more in depth guide that will guide you through creating multiple types of Spacelift resources through Terraform can be found at [the terraform-starter repository](https://github.com/spacelift-io/terraform-starter).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest a slight edit, other than that it looks good to me.

Suggested change
A more in depth guide that will guide you through creating multiple types of Spacelift resources through Terraform can be found at [the terraform-starter repository](https://github.com/spacelift-io/terraform-starter).
A more in-depth guide to creating multiple types of Spacelift resources with Terraform can be found at [the terraform-starter repository](https://github.com/spacelift-io/terraform-starter){: rel="nofollow"}.


## How it works

Expand Down