-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.go
46 lines (37 loc) · 811 Bytes
/
iam.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
38
39
40
41
42
43
44
45
46
package iam
import (
"github.com/aws/aws-sdk-go/service/iam"
"github.com/coinbase/step-asg-deployer/aws"
)
//////
// PROFILE
//////
// Profile struct
type Profile struct {
Path *string
Arn *string
}
// Find returns profile with name
func Find(iamClient aws.IAMAPI, profileName *string) (*Profile, error) {
profileOutput, err := iamClient.GetInstanceProfile(&iam.GetInstanceProfileInput{
InstanceProfileName: profileName,
})
if err != nil {
return nil, err
}
awsProfile := profileOutput.InstanceProfile
return &Profile{
Path: awsProfile.Path,
Arn: awsProfile.Arn,
}, nil
}
//////
// ROLE
//////
// RoleExists returns whether profile exists
func RoleExists(iamc aws.IAMAPI, roleName *string) error {
_, err := iamc.GetRole(&iam.GetRoleInput{
RoleName: roleName,
})
return err
}