Skip to content

Commit

Permalink
partial fargate
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianriobo committed Nov 24, 2023
1 parent 22a62e1 commit b46f507
Show file tree
Hide file tree
Showing 170 changed files with 109,403 additions and 1 deletion.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.2
github.com/pulumi/pulumi-aws/sdk/v6 v6.9.0
github.com/pulumi/pulumi-awsx/sdk/v2 v2.3.0
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.18.0
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.18.0
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.18.0
Expand Down Expand Up @@ -62,6 +63,7 @@ require (
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pulumi/esc v0.5.6 // indirect
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.18.0 // indirect
github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
Expand Down
6 changes: 5 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ github.com/pulumi/esc v0.5.6 h1:4WV3X7OEVcChIwbSG+JxhZDdmq/q7lFPaSjHRYlPwmI=
github.com/pulumi/esc v0.5.6/go.mod h1:wpwNfVS5fV7Kd51j4dJ6FWYlKfxdqyppgp0gtkzqH04=
github.com/pulumi/pulumi-aws/sdk/v6 v6.9.0 h1:lXAuHTQpahA/AOE7MstBsoQi4E6by1nKII1WRO3oq+w=
github.com/pulumi/pulumi-aws/sdk/v6 v6.9.0/go.mod h1:j9uDjldfM/PmtXTpmRtHdsmsay3bW4pVYb4cI6OdAvw=
github.com/pulumi/pulumi-awsx/sdk/v2 v2.3.0 h1:UEdUQKep1Y4vr6YasSO2tXRGJWaoVVQfpD87sEFYhTI=
github.com/pulumi/pulumi-awsx/sdk/v2 v2.3.0/go.mod h1:0LFX4V3PY88rBBfRIIA4DxOTAI/GEffwvjnFGccfTyw=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.18.0 h1:Xk3x640pst+9o5+6D2gB1e33xa6fZ9Tn1cCAI6DiKMg=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.18.0/go.mod h1:fZZHYvj8kozGI5e6jY81LTCY8Wvr4ir82qZmmyVD6LI=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.18.0 h1:S0mM5tJw6QxQytXLWZQAt9XAmCIojGJ5k3edRXeR0mo=
Expand All @@ -313,6 +315,8 @@ github.com/pulumi/pulumi-azure-native-sdk/v2 v2.18.0 h1:NTGY8qa8gqonMkuBASVHtpf2
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.18.0/go.mod h1:QQ0bJDSjYrzgTyw73XakHwB9+5S9/GkNvjaUDBHQz2A=
github.com/pulumi/pulumi-command/sdk v0.9.2 h1:2siCFR8pS2sSwXkeWiLrprGEtBL54FsHTzdyl125UuI=
github.com/pulumi/pulumi-command/sdk v0.9.2/go.mod h1:VeUXTI/iTgKVjRChRJbLRlBVGxAH+uymscfwzBC2VqY=
github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 h1:gQC2As+wE8QflbLCG90jLaKwIpqW3yl1y327Jj6ovbI=
github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3/go.mod h1:i19ZhFjFQrngtXYLHp3kjZNRmnEnq/DUdXK6/CBk77o=
github.com/pulumi/pulumi-random/sdk/v4 v4.14.0 h1:ljy/gUeur2kZZWL3JPy0J9zLDYKKA0zMd1mT7xrpI7s=
github.com/pulumi/pulumi-random/sdk/v4 v4.14.0/go.mod h1:XqGATLB6KKuWRDhWvHO6YVwv0DRW/cK/pWzNkuhMB24=
github.com/pulumi/pulumi-tls/sdk/v4 v4.11.1 h1:tXemWrzeVTqG8zq6hBdv1TdPFXjgZ+dob63a/6GlF1o=
Expand Down Expand Up @@ -768,7 +772,7 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
lukechampine.com/frand v1.4.2 h1:RzFIpOvkMXuPMBb9maa4ND4wjBn71E1Jpf8BzJHMaVw=
lukechampine.com/frand v1.4.2/go.mod h1:4S/TM2ZgrKejMcKMbeLjISpJMO+/eZ1zu3vYX9dtj3s=
pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA=
pgregory.net/rapid v0.6.1 h1:4eyrDxyht86tT4Ztm+kvlyNBLIk071gR+ZQdhphc9dQ=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
45 changes: 45 additions & 0 deletions pkg/provider/aws/action/mac/mac-dh.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import (
"github.com/adrianriobo/qenvs/pkg/provider/util/output"
"github.com/adrianriobo/qenvs/pkg/util/logging"
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
awsECS "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs"
"github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
Expand Down Expand Up @@ -81,3 +84,45 @@ func (r *MacRequest) manageResultsDedicatedHost(stackResult auto.UpResult) (*str
}
return &dhID, &dhAZ, nil
}

func (r *MacRequest) ScheduleDestroy(ctx *pulumi.Context) error {
// https://medium.com/@nilangav/set-up-scheduled-tasks-with-aws-fargate-using-cloudformation-templates-b7bd2f7db46b

cluster, err := awsECS.NewCluster(ctx, "cluster",
&awsECS.ClusterArgs{})
if err != nil {
return err
}

fs, err := ecs.NewFargateService(ctx,
resourcesUtil.GetResourceName(r.Prefix, awsMacMachineID, "fg"),
&ecs.FargateServiceArgs{
Cluster: cluster.Arn,
TaskDefinitionArgs: &ecs.FargateServiceTaskDefinitionArgs{},
})
if err != nil {
return err
}

cloudwatch.NewEventRule(ctx,
resourcesUtil.GetResourceName(r.Prefix, awsMacMachineID, "mac-dh-event-destroy"),
&cloudwatch.EventRuleArgs{
Description: pulumi.String("Destroy event for mac dedicated host"),
Name: pulumi.String(resourcesUtil.GetResourceName(r.Prefix,
awsMacMachineID, "mac-dh-event-desotry")),

// ScheduleExpression: ,
},
)

cloudwatch.NewEventTarget(ctx,
resourcesUtil.GetResourceName(r.Prefix, awsMacMachineID, "mac-dh-event-destroy"),
&cloudwatch.EventTargetArgs{
EcsTarget: cloudwatch.EventTargetEcsTargetArgs{
TaskCount: pulumi.IntPtr(1),
TaskDefinitionArn: fs.TaskDefinition.Arn(),
},
})

return fmt.Errorf("not implemented yet")
}
Loading

0 comments on commit b46f507

Please sign in to comment.