Skip to content

Commit

Permalink
Systemd with logging nice
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Nov 10, 2023
1 parent bfe3593 commit d865c2d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/ssh/aem.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "aem_instance" "single" {

system {
data_dir = local.aem_single_compose_dir
bootstrap = <<SHELL
bootstrap_script = <<SHELL
#!/bin/sh
(
echo "Mounting EBS volume into data directory"
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/instance_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/wttech/terraform-provider-aem/internal/utils"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -86,7 +87,8 @@ func (ic *InstanceClient) create() error {

func (ic *InstanceClient) saveProfileScript() error {
envFile := fmt.Sprintf("/etc/profile.d/%s.sh", ServiceName)
var envMap map[string]string
envMap := map[string]string{}
maps.Copy(envMap, ic.cl.Env)
ic.data.System.Env.ElementsAs(ic.ctx, &envMap, true)

ic.cl.Sudo = true
Expand Down Expand Up @@ -198,7 +200,7 @@ func (ic *InstanceClient) ReadStatus() (InstanceStatus, error) {
}

func (ic *InstanceClient) bootstrap() error {
return ic.runScript("bootstrap", ic.data.System.Bootstrap.ValueString(), ".")
return ic.runScript("bootstrap", ic.data.System.BootstrapScript.ValueString(), ".")
}

func (ic *InstanceClient) runScript(name, cmdScript, dir string) error {
Expand Down
14 changes: 7 additions & 7 deletions internal/provider/instance_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ type InstanceResourceModel struct {
} `tfsdk:"client"`
Files types.Map `tfsdk:"files"`
System struct {
DataDir types.String `tfsdk:"data_dir"`
WorkDir types.String `tfsdk:"work_dir"`
Env types.Map `tfsdk:"env"`
ServiceConfig types.String `tfsdk:"service_config"`
User types.String `tfsdk:"user"`
Bootstrap types.String `tfsdk:"bootstrap"`
DataDir types.String `tfsdk:"data_dir"`
WorkDir types.String `tfsdk:"work_dir"`
Env types.Map `tfsdk:"env"`
ServiceConfig types.String `tfsdk:"service_config"`
User types.String `tfsdk:"user"`
BootstrapScript types.String `tfsdk:"bootstrap_script"`
} `tfsdk:"system"`
Compose struct {
Download types.Bool `tfsdk:"download"`
Expand Down Expand Up @@ -98,7 +98,7 @@ func (r *InstanceResource) Schema(ctx context.Context, req resource.SchemaReques
},
"system": schema.SingleNestedBlock{
Attributes: map[string]schema.Attribute{
"bootstrap": schema.StringAttribute{
"bootstrap_script": schema.StringAttribute{
MarkdownDescription: "Script executed once after connecting to the instance. Typically used for: providing AEM library files (quickstart.jar, license.properties, service packs), mounting data volume, etc. Forces instance recreation if changed.",
Optional: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
Expand Down

0 comments on commit d865c2d

Please sign in to comment.