Skip to content

Commit 2bc3ce8

Browse files
committed
Upgrade terraform providers, capabilities template
1 parent e9f246b commit 2bc3ce8

8 files changed

Lines changed: 130 additions & 22 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ override.tf.json
2828
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
2929
# example: *tfplan*
3030

31-
.nullstone.json
32-
.terraform.lock.hcl
3331
__backend__.tf
3432
.nullstone/active-workspace.yml

.nullstone/module.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ subplatform: ""
1111
type: server/ec2
1212
appCategories: []
1313
is_public: true
14+
tool_name: "terraform"

.terraform.lock.hcl

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
# 0.2.0 (Sep 22, 2025)
2+
* Upgraded terraform providers.
3+
14
# 0.1.0 (Aug 08, 2023)
25
* Initial release.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lock-providers:
2+
terraform providers lock -platform=linux_amd64 -platform=linux_arm64 -platform=darwin_amd64 -platform=darwin_arm64 -platform=windows_amd64

capabilities.tf.tmpl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{{ range . -}}
22
provider "ns" {
3-
capability_id = {{ .Id }}
4-
alias = "cap_{{ .Id }}"
3+
capability_name = "{{ .Name }}"
4+
alias = "{{ .TfModuleName }}"
55
}
66

77
module "{{ .TfModuleName }}" {
88
source = "{{ .Source }}/any"
9-
{{ if (ne .SourceVersion "latest") }}version = "{{ .SourceVersion }}"{{ end }}
9+
{{- if (ne .SourceVersion "latest") }}
10+
version = "{{ .SourceVersion }}"
11+
{{- end }}
1012

1113
app_metadata = local.app_metadata
12-
{{ range $key, $value := .Variables -}}
13-
{{ if not $value.Unused -}}{{ if $value.Value -}}
14+
{{ range $key, $value := .Variables -}}{{- if $value.HasValue }}
1415
{{ $key }} = jsondecode({{ $value.Value | to_json_string }})
1516
{{- end -}}{{- end }}
16-
{{ end }}
17+
1718
providers = {
18-
ns = ns.cap_{{ .Id}}
19+
ns = ns.{{ .TfModuleName }}
1920
}
2021
}
2122
{{ end }}
@@ -25,10 +26,10 @@ module "caps" {
2526
}
2627

2728
locals {
28-
modules = [
29+
modules = [
2930
{{- range $index, $element := .ExceptNeedsDestroyed.TfModuleAddrs -}}
3031
{{ if $index }}, {{ end }}{{ $element }}
3132
{{- end -}}
3233
]
33-
capabilities = module.caps.outputs
34+
capabilities = module.caps.outputs
3435
}

outputs.tf

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output "region" {
2-
value = data.aws_region.this.name
2+
value = data.aws_region.this.region
33
description = "string ||| The AWS region where the EC2 instance resides."
44
}
55

@@ -19,20 +19,12 @@ output "adminer" {
1919
sensitive = true
2020
}
2121

22-
locals {
23-
// Private and public URLs are shown in the Nullstone UI
24-
// Typically, they are created through capabilities attached to the application
25-
// If this module has URLs, add them here as list(string)
26-
additional_private_urls = [aws_instance.this.private_dns]
27-
additional_public_urls = []
28-
}
29-
3022
output "private_urls" {
31-
value = concat([for url in try(local.capabilities.private_urls, []) : url["url"]], local.additional_private_urls)
23+
value = local.private_urls
3224
description = "list(string) ||| A list of URLs only accessible inside the network"
3325
}
3426

3527
output "public_urls" {
36-
value = concat([for url in try(local.capabilities.public_urls, []) : url["url"]], local.additional_public_urls)
28+
value = local.public_urls
3729
description = "list(string) ||| A list of URLs accessible to the public"
3830
}

urls.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
locals {
2+
// Private and public URLs are shown in the Nullstone UI
3+
// Typically, they are created through capabilities attached to the application
4+
// If this module has URLs, add them here as list(string)
5+
additional_private_urls = [aws_instance.this.private_dns]
6+
additional_public_urls = []
7+
8+
private_urls = concat([for url in try(local.capabilities.private_urls, []) : url["url"]], local.additional_private_urls)
9+
public_urls = concat([for url in try(local.capabilities.public_urls, []) : url["url"]], local.additional_public_urls)
10+
}
11+
12+
locals {
13+
uri_matcher = "^(?:(?P<scheme>[^:/?#]+):)?(?://(?P<authority>[^/?#]*))?"
14+
}
15+
16+
locals {
17+
authority_matcher = "^(?:(?P<user>[^@]*)@)?(?:(?P<host>[^:]*))(?:[:](?P<port>[\\d]*))?"
18+
// These tests are here to verify the authority_matcher regex above
19+
// To verify, uncomment the following lines and issue "echo 'local.tests' | terraform console"
20+
/*
21+
tests = tomap({
22+
"nullstone.io" : regex(local.authority_matcher, "nullstone.io"),
23+
"brad@nullstone.io" : regex(local.authority_matcher, "brad@nullstone.io"),
24+
"brad:password@nullstone.io" : regex(local.authority_matcher, "brad:password@nullstone.io"),
25+
"nullstone.io:9000" : regex(local.authority_matcher, "nullstone.io:9000"),
26+
"brad@nullstone.io:9000" : regex(local.authority_matcher, "brad@nullstone.io:9000"),
27+
"brad:password@nullstone.io:9000" : regex(local.authority_matcher, "brad:password@nullstone.io:9000"),
28+
})
29+
*/
30+
}
31+
32+
locals {
33+
private_hosts = [for url in local.private_urls : lookup(regex(local.authority_matcher, lookup(regex(local.uri_matcher, url), "authority")), "host")]
34+
public_hosts = [for url in local.public_urls : lookup(regex(local.authority_matcher, lookup(regex(local.uri_matcher, url), "authority")), "host")]
35+
}

0 commit comments

Comments
 (0)