Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AWS Cloud9 #264

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Flags:
-h, --help help for google
-o, --path-output string (default "generated")
-p, --path-pattern string {output}/{provider}/custom/{service}/ (default "{output}/{provider}/{service}/")
--projects strings
--projects strings
-z, --regions strings europe-west1, (default [global])
-r, --resources strings firewalls,networks
-s, --state string local or bucket (default "local")
Expand Down Expand Up @@ -360,6 +360,8 @@ In that case terraformer will not know with which region resources are associate
* `aws_launch_template`
* `budgets`
* `aws_budgets_budget`
* `cloud9`
* `aws_cloud9_environment_ec2`
* `cloudfront`
* `aws_cloudfront_distribution`
* `cloudformation`
Expand Down
1 change: 1 addition & 0 deletions providers/aws/aws_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (p *AWSProvider) GetSupportedService() map[string]terraform_utils.ServiceGe
"alb": &AlbGenerator{},
"auto_scaling": &AutoScalingGenerator{},
"budgets": &BudgetsGenerator{},
"cloud9": &Cloud9Generator{},
"cloudformation": &CloudFormationGenerator{},
"cloudfront": &CloudFrontGenerator{},
"cloudtrail": &CloudTrailGenerator{},
Expand Down
52 changes: 52 additions & 0 deletions providers/aws/cloud9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2019 The Terraformer Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package aws

import (
"github.com/GoogleCloudPlatform/terraformer/terraform_utils"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloud9"
)

var cloud9AllowEmptyValues = []string{"tags."}

type Cloud9Generator struct {
AWSService
}

func (g Cloud9Generator) createResources(environmentIds []*string) []terraform_utils.Resource {
var resources []terraform_utils.Resource
for _, environmentId := range environmentIds {
resourceName := aws.StringValue(environmentId)
resources = append(resources, terraform_utils.NewSimpleResource(
resourceName,
resourceName,
"aws_cloud9_environment_ec2",
"aws",
cloud9AllowEmptyValues))
}
return resources
}

func (g *Cloud9Generator) InitResources() error {
sess := g.generateSession()
svc := cloud9.New(sess)
output, err := svc.ListEnvironments(&cloud9.ListEnvironmentsInput{})
if err != nil {
return err
}
g.Resources = g.createResources(output.EnvironmentIds)
return nil
}