-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changing subcommands and adjusting the s3 bucket creation
- Loading branch information
1 parent
e86e3a0
commit e10f68c
Showing
18 changed files
with
110 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ tests | |
cover.out | ||
|
||
aft-deployment | ||
example-output | ||
|
||
pre-flight.sh | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
Copyright © 2023 Edgar Costa [email protected] | ||
*/ | ||
|
||
package aft | ||
|
||
import ( | ||
"github.com/edgarsilva948/aftctl/cmd/aft/deploy" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Cmd represents the root command for the "deploy" functionality. | ||
var Cmd = &cobra.Command{ | ||
Use: "aft", | ||
Short: "Deploy AFT from from stdin", | ||
Long: "Deploy AFT from from stdin", | ||
} | ||
|
||
func init() { | ||
|
||
Cmd.AddCommand(deploy.Cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,9 @@ | |
Copyright © 2023 Edgar Costa [email protected] | ||
*/ | ||
|
||
package prereqs | ||
package deploy | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/edgarsilva948/aftctl/pkg/aws" | ||
"github.com/edgarsilva948/aftctl/pkg/initialcommit" | ||
"github.com/spf13/cobra" | ||
|
@@ -47,7 +45,7 @@ var args struct { | |
|
||
// Cmd is the exported command for the AFT prerequisites. | ||
var Cmd = &cobra.Command{ | ||
Use: "prereqs", | ||
Use: "deploy", | ||
Short: "Setup AFT prerequisites in AFT-Management Account", | ||
Long: "Setup AFT prerequisites in AFT-Management Account", | ||
Example: `# aftctl usage examples" | ||
|
@@ -61,10 +59,11 @@ func init() { | |
flags := Cmd.Flags() | ||
flags.SortFlags = false | ||
|
||
flags.StringVar( | ||
flags.StringVarP( | ||
&args.terraformStateBucketName, | ||
"terraform-state-bucket-name", | ||
"", | ||
"aft-deployment-terraform-tfstate", | ||
"Name of the deployment terraform state bucket", | ||
) | ||
|
||
|
@@ -259,12 +258,8 @@ func init() { | |
func run(cmd *cobra.Command, _ []string) { | ||
awsClient := aws.NewClient() | ||
|
||
// Trim names to remove any leading/trailing invisible characters | ||
terraformStateBucketName := strings.Trim(args.terraformStateBucketName, " \t") | ||
aftManagementAccountID := strings.Trim(args.aftManagementAccountID, " \t") | ||
|
||
interpolatedCodeSuiteBucketName := args.aftManagementAccountID + "-" + args.codePipelineBucketName | ||
|
||
interpolatedTerraformBucketName := args.aftManagementAccountID + "-" + args.terraformStateBucketName | ||
interpolatedZIPFileName := args.gitSourceRepo + ".zip" | ||
|
||
interpolatedCloudformationStackName := args.gitSourceRepo + "-cloudformation-stack" | ||
|
@@ -279,10 +274,10 @@ func run(cmd *cobra.Command, _ []string) { | |
codePipelineTrustRelationshipService, | ||
args.codePipelineRolePolicyName, | ||
args.region, | ||
aftManagementAccountID, | ||
args.aftManagementAccountID, | ||
args.gitSourceRepo, | ||
interpolatedCodeSuiteBucketName, | ||
terraformStateBucketName, | ||
interpolatedTerraformBucketName, | ||
) | ||
|
||
// Ensure the Code Build Service Role is created | ||
|
@@ -292,17 +287,17 @@ func run(cmd *cobra.Command, _ []string) { | |
codebuildTrustRelationshipService, | ||
args.codeBuildRolePolicyName, | ||
args.region, | ||
aftManagementAccountID, | ||
args.aftManagementAccountID, | ||
args.gitSourceRepo, | ||
interpolatedCodeSuiteBucketName, | ||
terraformStateBucketName, | ||
interpolatedTerraformBucketName, | ||
) | ||
|
||
// Ensure the tfstate bucket is created | ||
aws.EnsureS3BucketExists( | ||
awsClient.GetS3Client(), | ||
terraformStateBucketName, | ||
aftManagementAccountID, | ||
interpolatedTerraformBucketName, | ||
args.aftManagementAccountID, | ||
"test-kms-key-id", | ||
args.codeBuildRoleName, | ||
) | ||
|
@@ -311,15 +306,15 @@ func run(cmd *cobra.Command, _ []string) { | |
aws.EnsureS3BucketExists( | ||
awsClient.GetS3Client(), | ||
interpolatedCodeSuiteBucketName, | ||
aftManagementAccountID, | ||
args.aftManagementAccountID, | ||
"test-kms-key-id", | ||
args.codeBuildRoleName, | ||
) | ||
|
||
// Ensure the CodeCommit repo is created with initial code | ||
initialcommit.GenerateCommitFiles( | ||
args.gitSourceRepo, | ||
terraformStateBucketName, | ||
interpolatedTerraformBucketName, | ||
args.region, | ||
args.tfVersion, | ||
args.ctManagementAccountID, | ||
|
@@ -342,13 +337,6 @@ func run(cmd *cobra.Command, _ []string) { | |
interpolatedZIPFileName, | ||
) | ||
|
||
// Ensure the repository is created | ||
// aws.EnsureCodeCommitRepoExists( | ||
// awsClient.GetCodeCommitClient(), | ||
// args.gitSourceRepo, | ||
// args.gitSourceDescription, | ||
// ) | ||
|
||
// Ensure the repository is created | ||
aws.EnsureCloudformationExists( | ||
awsClient.CloudformationClient(), | ||
|
@@ -362,7 +350,7 @@ func run(cmd *cobra.Command, _ []string) { | |
// Ensure the Code Build Project is created | ||
aws.EnsureCodeBuildProjectExists( | ||
awsClient.CodebuildClient(), | ||
aftManagementAccountID, | ||
args.aftManagementAccountID, | ||
args.codeBuildDockerImage, | ||
args.projectName, | ||
args.gitSourceRepo, | ||
|
@@ -373,7 +361,7 @@ func run(cmd *cobra.Command, _ []string) { | |
// Ensure the Code Pipeline Pipe is created | ||
aws.EnsureCodePipelineExists( | ||
awsClient.CodePipelineClient(), | ||
aftManagementAccountID, | ||
args.aftManagementAccountID, | ||
args.codePipelineRoleName, | ||
args.pipelineName, | ||
interpolatedCodeSuiteBucketName, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
Copyright © 2023 Edgar Costa [email protected] | ||
*/ | ||
|
||
// Package prereqs contains tests for the prereqs cmd | ||
package prereqs | ||
// Package deploy contains tests for the prereqs cmd | ||
package deploy | ||
|
||
import ( | ||
ginkgo "github.com/onsi/ginkgo/v2" | ||
|
@@ -14,11 +14,7 @@ var _ = ginkgo.Describe("testing the prereqs steps", func() { | |
ginkgo.Context("stores the bucket name that will store the tfstate", func() { | ||
ginkgo.When("the command aftctl deploy prereqs --terraform-state-bucket-name=\"\" ", func() { | ||
ginkgo.It("should print an object with the version", func() { | ||
// cmd := &cobra.Command{ | ||
// Use: "prereqs", | ||
// } | ||
|
||
// gomega.Expect(out).To(gomega.MatchRegexp(expectedRegex)) | ||
}) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
Copyright © 2023 Edgar Costa [email protected] | ||
*/ | ||
|
||
package aft | ||
|
||
import ( | ||
ginkgo "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
var _ = ginkgo.Describe("Deploy Command", func() { | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.