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

Adding how-to guide for tf private registry for recipes #1073

Merged
merged 27 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
41707f5
Adding how-to guide for tf private registry for recipes
jasonviviano Feb 29, 2024
ee15fb8
Addressed feedback with Vishwanath's help.
jasonviviano Feb 29, 2024
21fb843
Fixed snippet
jasonviviano Feb 29, 2024
d7714a7
Apply suggestions from code review
jasonviviano Feb 29, 2024
640e1a8
Apply suggestions from code review
jasonviviano Mar 1, 2024
5b882fd
Merge branch 'v0.31' into jasonviviano/tf-howto-private
jasonviviano Mar 1, 2024
9e43ad2
Addressed feedback on howto-private-registry
jasonviviano Mar 4, 2024
608b5f3
Apply suggestions from code review
jasonviviano Mar 4, 2024
d8efc9f
Merge branch 'v0.31' into jasonviviano/tf-howto-private
jasonviviano Mar 4, 2024
ed7cbb1
Apply suggestions from code review
jasonviviano Mar 4, 2024
abef6ba
Addressed certain changes to the steps of the guide.
jasonviviano Mar 4, 2024
76066a6
Fixed naming.
jasonviviano Mar 4, 2024
271ab4e
Addressed feedback
jasonviviano Mar 4, 2024
31d12be
Merge branch 'v0.31' into jasonviviano/tf-howto-private
jasonviviano Mar 4, 2024
3f3a143
Spellcheck fix
jasonviviano Mar 4, 2024
d0da2ca
Merge branch 'v0.31' into jasonviviano/tf-howto-private
willtsai Mar 5, 2024
1eb4812
Apply suggestions from code review
jasonviviano Mar 5, 2024
3f3b8bf
Apply suggestions from code review
jasonviviano Mar 5, 2024
3c5fd89
Fixed snippet render
jasonviviano Mar 5, 2024
dcb6dec
Moved folder
jasonviviano Mar 5, 2024
f7f129c
Added a note linking to the limitations page
jasonviviano Mar 8, 2024
bc1c6eb
Added an explanation to the `resource` property.
jasonviviano Mar 8, 2024
ef09a99
Fixed spelling
jasonviviano Mar 8, 2024
42c49d9
Apply suggestions from code review
jasonviviano Mar 11, 2024
23b64a4
Addressed feedback on how-to guide
jasonviviano Mar 11, 2024
b2ebea1
Merge branch 'edge' into jasonviviano/tf-howto-private
jasonviviano Mar 11, 2024
035e149
Spellcheck fix
jasonviviano Mar 11, 2024
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
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
type: docs
title: "How-To: Set up a private registry for your Terraform Radius Recipes"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
linkTitle: "Set up a private registry"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
description: "Learn how to configure your Radius Environment to leverage your private registry as storage for your custom Recipe templates"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
weight: 500
categories: "How-To"
tags: ["recipes", "terraform"]
---

This how-to guide will provide an overview of how to:

- Configure a Radius Environment that leverages a [Radius secret store]({{< ref secretstore >}}) to register a [private Terraform registry](https://developer.hashicorp.com/terraform/registry/private) for your Recipe templates.
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

### Prerequisites

Before you get started, you'll need to make sure you have the following tools and resources:

- [rad CLI]({{< ref "installation#step-1-install-the-rad-cli" >}})
- [Radius Bicep VSCode extension]({{< ref "installation#step-2-install-the-vs-code-extension" >}})
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
### Step 1: Define a secret store resource

Radius provides support for defining Kubernetes Secrets as Bicep resources, through the Radius Secret Store. Users have the option to both leverage an existing Kubernetes Secret or define a new Kubernetes Secret in the resource, see the [Radius Secret Store schema]({{< ref secretstore >}}) for more information.


jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

Create a Bicep file `env.bicep` and define your resource:

{{< rad file="snippets/env.bicep" embed=true marker="//SECRETSTORE" >}}
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

> Note the property `pat` is a required property that refers to your personal access token, while `username` can be optional.
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

## Step 2: Define your Radius Recipe
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

Define your Radius Recipe, keep in mind that your `templatePath` should contain a `git::` prefix as per [Terraform requirements](https://developer.hashicorp.com/terraform/language/modules/sources#generic-git-repository).
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

{{< rad file="snippets/env.bicep" embed=true marker="//RECIPE" >}}


## Step 3: Define your Radius Recipe configurations

Radius provides a property `recipeConfig` which allows users to setup specific Git module sources for your Terraform Radius Recipes. Define this property in your Radius Environment resource, visit the [Radius Environment schema]({{< ref environment-schema >}}) page for more information.
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

{{< rad file="snippets/env.bicep" embed=true marker="//ENV" >}}

> Note the keys listed inside of the `pat` property should match your path name to the secret store.


jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
## Step 4: Deploy your Radius Environment

Deploy your new Radius Environment:

```
rad deploy env.bicep
```

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
## Cleanup

You can delete a Radius Environment by running the following command:

```
rad env delete prod
```

## Further reading

- [Recipes overview]({{< ref "/guides/recipes/overview" >}})
- [Radius Environments]({{< ref "/guides/deploy-apps/environments/overview" >}})
- [`rad recipe CLI reference`]({{< ref rad_recipe >}})
- [`rad env CLI reference`]({{< ref rad_env >}})
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import radius as radius

//ENV
resource env 'Applications.Core/environments@2023-10-01-preview' = {
name: 'prod'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
namespace: 'default'
}
recipeConfig: {
terraform: {
authentication:{
git:{
// PAT is a required key value, personal access token
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
pat:{
// This has to be a path name to the secret store
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
'dev.azure.com':{
secret: secretStoreGithub.id
}
}
}
}
}
//ENV
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
}


//RECIPE
recipes: {
'Applications.Datastores/mongoDatabases':{
default: {
templateKind: 'terraform'
// Git template path
templatePath: 'git::https://dev.azure.com/test-private-repo'
}
}
}
//RECIPE
}
}

//SECRETSTORE
resource secretStoreGithub 'Applications.Core/secretStores@2023-10-01-preview' = {
name: 'github'
properties:{
type: 'generic'
data: {
// Call it out in the documentation that pat is a required key value
pat: {
value: '<my-access-token>'
}
// Optional key value
username: {
value: '<my-username>'
}
}
}
}
//SECRETSTORE
Loading