-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws_internet_gateway.go
40 lines (33 loc) · 1.01 KB
/
aws_internet_gateway.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
package aws
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/jmcgill/formation/core"
)
type AwsInternetGatewayImporter struct {
}
// Lists all resources of this type
func (*AwsInternetGatewayImporter) Describe(meta interface{}) ([]*core.Instance, error) {
svc := meta.(*AWSClient).ec2conn
// Add code to list resources here
result, err := svc.DescribeInternetGateways(nil)
if err != nil {
return nil, err
}
existingInstances := result.InternetGateways
namer := NewTagNamer()
instances := make([]*core.Instance, len(existingInstances))
for i, existingInstance := range existingInstances {
gatewayId := existingInstance.InternetGatewayId
instances[i] = &core.Instance{
Name: namer.NameOrDefault(existingInstance.Tags, gatewayId),
ID: aws.StringValue(existingInstance.InternetGatewayId),
}
}
return instances, nil
}
// Describes which other resources this resource can reference
func (*AwsInternetGatewayImporter) Links() map[string]string {
return map[string]string{
"vpc_id": "aws_vpc.id",
}
}