Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

feat(ec2): name support for the launch template #1509

Merged
merged 1 commit into from
Jan 10, 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
1 change: 1 addition & 0 deletions pkg/providers/aws/ec2/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type LaunchConfiguration struct {

type LaunchTemplate struct {
Metadata defsecTypes.Metadata
Name defsecTypes.StringValue
Instance
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/terraform/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/google/uuid"
"github.com/zclconf/go-cty/cty"
)

Expand All @@ -22,6 +23,9 @@ func createPresetValues(b *Block) map[string]cty.Value {
switch b.TypeLabel() {
case "aws_iam_policy_document":
presets["json"] = cty.StringVal(b.ID())
// If the user leaves the name blank, Terraform will automatically generate a unique name
case "aws_launch_template":
presets["name"] = cty.StringVal(uuid.New().String())
Comment on lines +26 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to use a UUID here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to generate some unique value in case the user did not pass the name argument.

}

return presets
Expand Down