-
Notifications
You must be signed in to change notification settings - Fork 8
/
awssetup.go
37 lines (31 loc) · 1.22 KB
/
awssetup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package prepare
import (
"context"
"fmt"
"namespacelabs.dev/foundation/internal/compute"
"namespacelabs.dev/foundation/internal/console"
"namespacelabs.dev/foundation/internal/parsing/devhost"
"namespacelabs.dev/foundation/schema"
"namespacelabs.dev/foundation/std/tasks"
awsconf "namespacelabs.dev/foundation/universe/aws/configuration"
)
func PrepareAWSProfile(profileName string) compute.Computable[*schema.DevHost_ConfigureEnvironment] {
return compute.Map(
tasks.Action("prepare.aws-profile").HumanReadablef("Attaching AWS profile to Namespace's configuration"),
compute.Inputs().Str("profileName", profileName),
compute.Output{NotCacheable: true},
func(ctx context.Context, _ compute.Resolved) (*schema.DevHost_ConfigureEnvironment, error) {
hostEnv := &awsconf.Configuration{
Profile: profileName,
}
c, err := devhost.MakeConfiguration(hostEnv)
if err != nil {
return nil, err
}
fmt.Fprintf(console.Stdout(ctx), "[✓] Configure Namespace to use AWS profile %q.\n", profileName)
return c, nil
})
}