Git Product home page Git Product logo

tfc-getting-started's Introduction

HCP Terraform Getting Started

In this repo, you'll find a quick and easy path to get started using HCP Terraform with the Terraform CLI.

What's here?

This repo contains two main things:

  1. An example Terraform configuration which provisions some mock infrastructure to a fictitious cloud provider called "Fake Web Services" using the fakewebservices provider.
  2. A script which automatically handles all the setup required to start using Terraform with HCP Terraform.

Requirements

  • Terraform 0.14 or higher
  • The ability to run a bash script in your terminal
  • sed
  • curl
  • jq

Usage

1. Log in to HCP Terraform via the CLI

Run terraform login and follow the prompts to get an API token for Terraform to use. If you don't have a HCP Terraform account, you can create one during this step.

2. Clone this repo

git clone https://github.com/hashicorp/tfc-getting-started.git
cd tfc-getting-started

3. Run the setup script and follow the prompts

./scripts/setup.sh

Welcome to HCP Terraform!

tfc-getting-started's People

Contributors

annawinkler avatar barrettclark avatar brandonc avatar chrisarcand avatar clairevnext avatar fanciestw avatar hashicorp-tsccr[bot] avatar laurenolivia avatar maed223 avatar pandaman64 avatar pataquets avatar radditude avatar sebasslash avatar squaredloops avatar stretch96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tfc-getting-started's Issues

setup.sh - Failed to install provider, darwin_arm64

Hi, I'm using Terraform v1.3.7. When I try to run ./scripts/setup.sh I get the following error (executing terraform providers lock -platform=linux_amd64 fixes it though):

--------------------------------------------------------------------------
Getting Started with Terraform Cloud
-------------------------------------------------------------------------

Terraform Cloud offers secure, easy-to-use remote state management and allows
you to run Terraform remotely in a controlled environment. Terraform Cloud runs
can be performed on demand or triggered automatically by various events.

This script will set up everything you need to get started. You'll be
applying some example infrastructure - for free - in less than a minute.

First, we'll do some setup and configure Terraform to use Terraform Cloud.

Press any key to continue (ctrl-c to quit):

Creating an organization and workspace...

Writing remote backend configuration to backend.tf...

========================================================================

Ready to go; the example configuration is set up to use Terraform Cloud!

An example workspace named 'getting-started' was created for you.
You can view this workspace in the Terraform Cloud UI here:
https://app.terraform.io/app/example-org-40f7b3/workspaces/getting-started

Next, we'll run 'terraform init' to initialize the backend and providers:

$ terraform init

Press any key to continue (ctrl-c to quit):


Initializing the backend...

Successfully configured the backend "remote"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding latest version of hashicorp/fakewebservices...
- Installing hashicorp/fakewebservices v0.2.3...
- Installed hashicorp/fakewebservices v0.2.3 (unauthenticated)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

╷
│ Warning: Incomplete lock file information for providers
│
│ Due to your customized provider installation methods, Terraform was forced to calculate lock file checksums locally for
│ the following providers:
│   - hashicorp/fakewebservices
│
│ The current .terraform.lock.hcl file only includes checksums for darwin_arm64, so Terraform running on another platform
│ will fail to install these providers.
│
│ To calculate additional checksums for another platform, run:
│   terraform providers lock -platform=linux_amd64
│ (where linux_amd64 is the platform to generate)
╵

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

...

========================================================================

Now it’s time for 'terraform plan', to see what changes Terraform will perform:

$ terraform plan

Press any key to continue (ctrl-c to quit):

Running plan in the remote backend. Output will stream here. Pressing Ctrl-C
will stop streaming the logs, but will not stop the plan running remotely.

Preparing the remote plan...

To view this run in a browser, visit:
https://app.terraform.io/app/example-org-40f7b3/getting-started/runs/run-aVeNZTacX83kT2Zt

Waiting for the plan to start...

Terraform v1.3.7
on linux_amd64
Initializing plugins and modules...

Initializing Terraform Cloud...

Initializing provider plugins...
- Reusing previous version of hashicorp/fakewebservices from the dependency lock file
- Installing hashicorp/fakewebservices v0.2.3...
╷
│ Error: Failed to install provider
│
│ Error while installing hashicorp/fakewebservices v0.2.3: the current
│ package for registry.terraform.io/hashicorp/fakewebservices 0.2.3 doesn't
│ match any of the checksums previously recorded in the dependency lock file;
│ for more information:
│ https://www.terraform.io/language/provider-checksum-verification
╵

Operation failed: failed running terraform init (exit 1)

darwin_arm64 build error with fakewebservices

I'm trying to follow Terraform Cloud Getting Started but getting below error on new Apple Macbook with M1 chip

Terraform Version

Terraform v1.0.2
on darwin_arm64

Debug Output

tfc-getting-started % ./scripts/setup.sh
...

$ terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/fakewebservices...
╷
│ Error: Incompatible provider version
│ 
│ Provider registry.terraform.io/hashicorp/fakewebservices v0.2.1 does not have a package available for your current platform, darwin_arm64.
│ 

References

related issue
hashicorp/terraform#29186

setup script parse error

When I run

./scripts/setup.sh

I get

parse error: Invalid numeric literal at line 1, column 10

Credentials Folder Not Found On Windows OS

The setup script fails with the following message when running it on Windows using GitBash.

$ ./scripts/setup.sh
jq: error: Could not open file C:/Users/Claire Knutson/.terraform.d/credentials.tfrc.json: No such file or directory

The reason is that the terraform login command is using the $APPDATA environment variable, not $HOME when run on a Windows operating system. In conjunction with using a different folder, the subfolder name, terraform.d is not prefixed with a period like it is for Unix operating systems.

This was previously reported in issue #20 and is still unresolved. I'll open a PR on the scripts/setup.sh file in this repo to account for the differences.

setup.sh (terraform init) fails with "operation not supported"

Here's there situation, one, I'm new to terraform (apologies for newbieness), two, its in a Linux container on ChromeOS (probably why this is failing), three I'm running the setup.sh bash script fails with the following:

Initializing the backend...

│ Error: Error locking state: [{%!s(tfdiags.Severity=69) Error acquiring the state lock Error message: 2 errors occurred:
│ * operation not supported
│ * open .terraform/.terraform.tfstate.lock.info: no such file or directory



│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended. }]


Here's the version:
Terraform v1.0.9
on linux_amd64

I tried running it with a local account and sudo. Both have the same issue ... lastly, and this may be something stupid, but I had to chmod +x the setup.sh file to run it.

Thank you for any advice or help, it's much appreciated! :)

Sincerely,
Mike the terraform newbie

internal server error when running scrips/setup.sh

using commit e44fbbe8d7bca6ed745e03d50c9a50b100de8b5f:

~/src/tfc-getting-started main 11s
ε  scripts/setup.sh


--------------------------------------------------------------------------
Getting Started with Terraform Cloud
-------------------------------------------------------------------------

Terraform Cloud offers secure, easy-to-use remote state management and allows
you to run Terraform remotely in a controlled environment. Terraform Cloud runs
can be performed on demand or triggered automatically by various events.

This script will set up everything you need to get started. You'll be
applying some example infrastructure - for free - in less than a minute.

First, we'll do some setup and configure Terraform to use Terraform Cloud.

Press any key to continue (ctrl-c to quit):

Creating an organization and workspace...
An unknown error occurred: {"errors":[{"status":"500","title":"internal server error"}]}
terraform version
Terraform v1.1.0-dev
on darwin_amd64

Unsupported argument on provider.tf line 8 sensitive is not expected here.

In PR #5 the sensitive flag was added to the provider.tf file, however that feature was added in Terraform 0.14.

The readme.md and scripts/setup.sh specify that Terraform 0.13 or above is required, not 0.14.

If you run the setup.sh script while running Terraform 0.13.x then you will receive the following error:

Error: Unsupported argument

  on provider.tf line 8, in variable "provider_token":
   8:   sensitive = true

An argument named "sensitive" is not expected here.

The quick solution is to either remove line 8 (containing sensitive = true) or to upgrade to Terraform 0.14.x.

The best fix is to update the readme.md and setup.sh to specify / check for 0.14.

fails for credential helper

The setup script seems to expect credentials stored in cleartext.

$ ./scripts/setup.sh
jq: error: Could not open file /home/luism/.terraform.d/credentials.tfrc.json: No such file or directory
$ cat ~/.terraformrc
credentials_helper "keychain" {}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.