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

(TF-18670) feat: support references for identity tokens and their attributes #388

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion internal/schema/refscope/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ var (
ResourceScope = lang.ScopeId("resource")
VariableScope = lang.ScopeId("variable")

ComponentScope = lang.ScopeId("component")
ComponentScope = lang.ScopeId("component")
IdentityTokenScope = lang.ScopeId("identity_token")
)
4 changes: 2 additions & 2 deletions internal/schema/stacks/1.9/deployment_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package schema
import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
"github.com/hashicorp/terraform-schema/internal/schema/tokmod"
"github.com/zclconf/go-cty/cty"
)

func deploymentBlockSchema() *schema.BlockSchema {
Expand All @@ -32,7 +32,7 @@ func deploymentBlockSchema() *schema.BlockSchema {
IsOptional: true,
Constraint: schema.Map{
Name: "map of variable references",
Elem: schema.Reference{OfScopeId: refscope.VariableScope},
Elem: schema.AnyExpression{OfType: cty.DynamicPseudoType},
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions internal/schema/stacks/1.9/identity_token_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ package schema
import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
"github.com/hashicorp/terraform-schema/internal/schema/tokmod"
"github.com/zclconf/go-cty/cty"
)

func identityTokenBlockSchema() *schema.BlockSchema {
return &schema.BlockSchema{
Description: lang.PlainText("An identity token block is a definition of a JSON Web Token (JWT) that will be generated for a given deployment if referenced in the inputs for that deployment block. The block label defines the token name, which must be unique within the stack."),
Address: &schema.BlockAddrSchema{
Steps: []schema.AddrStep{
schema.StaticStep{Name: "identity_token"},
schema.LabelStep{Index: 0},
},
FriendlyName: "identity_token",
ScopeId: refscope.IdentityTokenScope,
AsReference: true,
InferBody: true,
BodyAsData: true,
},
Labels: []*schema.LabelSchema{
{
Name: "name",
Expand All @@ -32,6 +44,16 @@ func identityTokenBlockSchema() *schema.BlockSchema {
Elem: schema.AnyExpression{OfType: cty.String},
},
},
"jwt": {
Description: lang.Markdown("Token that will be generated that you can pass to a given provider's configuration for OIDC/JWT authentication"),
IsComputed: true,
Constraint: schema.AnyExpression{OfType: cty.String},
},
"jwt_filename": {
Description: lang.Markdown("Path to the token that will be generated on the filesystem that you can pass to a given provider's configuration for OIDC/JWT authentication"),
IsComputed: true,
Constraint: schema.AnyExpression{OfType: cty.String},
},
},
},
}
Expand Down