diff --git a/internal/pkg/cli/env_show_test.go b/internal/pkg/cli/env_show_test.go index 77af75ba25b..f55ef853496 100644 --- a/internal/pkg/cli/env_show_test.go +++ b/internal/pkg/cli/env_show_test.go @@ -324,7 +324,7 @@ Resources ) }, - wantedContent: "{\"environment\":{\"app\":\"testApp\",\"name\":\"testEnv\",\"region\":\"us-west-2\",\"accountID\":\"123456789012\",\"prod\":false,\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\"},\"services\":[{\"app\":\"testApp\",\"name\":\"testSvc1\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc2\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc3\",\"type\":\"load-balanced\"}],\"tags\":{\"copilot-application\":\"testApp\",\"copilot-environment\":\"testEnv\",\"key1\":\"value1\",\"key2\":\"value2\"},\"resources\":[{\"type\":\"AWS::IAM::Role\",\"physicalID\":\"testApp-testEnv-CFNExecutionRole\"},{\"type\":\"testApp-testEnv-Cluster\",\"physicalID\":\"AWS::ECS::Cluster-jI63pYBWU6BZ\"}],\"environment_vpc\":{\"ID\":\"\",\"PublicSubnetIDs\":null,\"PrivateSubnetIDs\":null}}\n", + wantedContent: "{\"environment\":{\"app\":\"testApp\",\"name\":\"testEnv\",\"region\":\"us-west-2\",\"accountID\":\"123456789012\",\"prod\":false,\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\"},\"services\":[{\"app\":\"testApp\",\"name\":\"testSvc1\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc2\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc3\",\"type\":\"load-balanced\"}],\"tags\":{\"copilot-application\":\"testApp\",\"copilot-environment\":\"testEnv\",\"key1\":\"value1\",\"key2\":\"value2\"},\"resources\":[{\"type\":\"AWS::IAM::Role\",\"physicalID\":\"testApp-testEnv-CFNExecutionRole\"},{\"type\":\"testApp-testEnv-Cluster\",\"physicalID\":\"AWS::ECS::Cluster-jI63pYBWU6BZ\"}],\"environmentVPC\":{\"id\":\"\",\"publicSubnetIDs\":null,\"privateSubnetIDs\":null}}\n", }, } diff --git a/internal/pkg/describe/env.go b/internal/pkg/describe/env.go index d4dca0ebd8f..6669718469e 100644 --- a/internal/pkg/describe/env.go +++ b/internal/pkg/describe/env.go @@ -26,14 +26,14 @@ type EnvDescription struct { Services []*config.Workload `json:"services"` Tags map[string]string `json:"tags,omitempty"` Resources []*CfnResource `json:"resources,omitempty"` - EnvironmentVPC EnvironmentVPC `json:"environment_vpc"` + EnvironmentVPC EnvironmentVPC `json:"environmentVPC"` } // EnvironmentVPC holds the ID of the environment's VPC configuration. type EnvironmentVPC struct { - ID string - PublicSubnetIDs []string - PrivateSubnetIDs []string + ID string `json:"id"` + PublicSubnetIDs []string `json:"publicSubnetIDs"` + PrivateSubnetIDs []string `json:"privateSubnetIDs"` } // EnvDescriber retrieves information about an environment. @@ -130,7 +130,7 @@ func (d *EnvDescriber) Version() (string, error) { } func (d *EnvDescriber) loadStackInfo() (map[string]string, EnvironmentVPC, error) { - environmentVPC := EnvironmentVPC{} + var environmentVPC EnvironmentVPC tags := make(map[string]string) envStack, err := d.stackDescriber.Stack(stack.NameForEnv(d.app, d.env.Name)) diff --git a/internal/pkg/describe/env_test.go b/internal/pkg/describe/env_test.go index 61eaf30f206..f47c3014f7b 100644 --- a/internal/pkg/describe/env_test.go +++ b/internal/pkg/describe/env_test.go @@ -341,7 +341,7 @@ func TestEnvDescription_JSONString(t *testing.T) { Type: "load-balanced", } allSvcs := []*config.Workload{testSvc1, testSvc2, testSvc3} - wantedContent := "{\"environment\":{\"app\":\"testApp\",\"name\":\"testEnv\",\"region\":\"us-west-2\",\"accountID\":\"123456789012\",\"prod\":false,\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\",\"customConfig\":{}},\"services\":[{\"app\":\"testApp\",\"name\":\"testSvc1\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc2\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc3\",\"type\":\"load-balanced\"}],\"tags\":{\"key1\":\"value1\",\"key2\":\"value2\"},\"resources\":[{\"type\":\"AWS::IAM::Role\",\"physicalID\":\"testApp-testEnv-CFNExecutionRole\"},{\"type\":\"testApp-testEnv-Cluster\",\"physicalID\":\"AWS::ECS::Cluster-jI63pYBWU6BZ\"}],\"environment_vpc\":{\"ID\":\"\",\"PublicSubnetIDs\":null,\"PrivateSubnetIDs\":null}}\n" + wantedContent := "{\"environment\":{\"app\":\"testApp\",\"name\":\"testEnv\",\"region\":\"us-west-2\",\"accountID\":\"123456789012\",\"prod\":false,\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\",\"customConfig\":{}},\"services\":[{\"app\":\"testApp\",\"name\":\"testSvc1\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc2\",\"type\":\"load-balanced\"},{\"app\":\"testApp\",\"name\":\"testSvc3\",\"type\":\"load-balanced\"}],\"tags\":{\"key1\":\"value1\",\"key2\":\"value2\"},\"resources\":[{\"type\":\"AWS::IAM::Role\",\"physicalID\":\"testApp-testEnv-CFNExecutionRole\"},{\"type\":\"testApp-testEnv-Cluster\",\"physicalID\":\"AWS::ECS::Cluster-jI63pYBWU6BZ\"}],\"environmentVPC\":{\"id\":\"\",\"publicSubnetIDs\":null,\"privateSubnetIDs\":null}}\n" // GIVEN ctrl := gomock.NewController(t)