https://github.com/fireflycons/terraform-provider-localos
Data Source provider to get information from the local OS on which you are running Terraform
https://github.com/fireflycons/terraform-provider-localos
Last synced: 5 months ago
JSON representation
Data Source provider to get information from the local OS on which you are running Terraform
- Host: GitHub
- URL: https://github.com/fireflycons/terraform-provider-localos
- Owner: fireflycons
- License: mpl-2.0
- Created: 2023-10-10T19:58:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-26T20:23:12.000Z (over 2 years ago)
- Last Synced: 2025-09-03T17:25:15.058Z (10 months ago)
- Language: Go
- Size: 80.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Terraform Provider localos
The [localos provider](./docs/index.md) contains data sources that get information about the machine running `terraform apply`
The documentation for the provider can be found on the [Terraform Registry](https://registry.terraform.io/providers/fireflycons/localos/latest/docs)
## Example
```hcl
terraform {
required_providers {
localos = {
source = "fireflycons/localos"
version = "0.1.1"
}
}
}
provider "localos" {}
data "localos_folders" "folders" {}
data "localos_public_ip" "my_ip" {}
# Create a key pair
resource "tls_private_key" "pk" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "aws_key_pair" "generated_key" {
key_name = "test-kp"
public_key = tls_private_key.pk.public_key_openssh
}
# Save the PK to OS specific SSH keys folder
resource "local_sensitive_file" "private_key" {
content = tls_private_key.pk.private_key_pem
filename = "${data.localos_folders.folders.ssh}/test-kp-pvt.pem"
}
# Create a security group that restricts access to only my public IP
resource "aws_security_group" "only_me" {
name = "only_me"
description = "Allow all access only from my workstation"
vpc_id = var.vpc_id
ingress {
description = "Any from my IP"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
data.localos_public_ip.my_ip.cidr
]
}
}
```
## Requirements to build/develop
- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
- [Go](https://golang.org/doc/install) >= 1.20
## Using the provider
The data sources are
* [localos_info](./docs/data-sources/info.md) - Retrieves operating system (windows, linux etc), architecture (amd64, arm64 etc), and all environment variables.
* [localos_folders](./docs/data-sources/folders.md) - Gets paths to local folders of interest, currently user's home and ssh key directories.
* [localos_public_ip](./docs/data-sources/public_ip.md) - Gets the public IP of your workstation as an IP address and a /32 CIDR. Useful for configuring routes, firewalls etc for private infrastructure.
## Developing the Provider
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
To generate or update documentation, run `go generate`.
In order to run the full suite of Acceptance tests, run `make testacc`.
*Note:* Acceptance tests create real resources, and often cost money to run.
```shell
make testacc
```