-
Notifications
You must be signed in to change notification settings - Fork 428
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
chore(manifest): add from_tag for workload #3727
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,8 +18,9 @@ const ( | |||||
internetGatewayIDPrefix = "igw-" | ||||||
cloudFrontPrefixListName = "com.amazonaws.global.cloudfront.origin-facing" | ||||||
|
||||||
// TagFilterName is the filter name format for tag filters | ||||||
TagFilterName = "tag:%s" | ||||||
// FmtTagFilter is the filter name format for tag filters | ||||||
FmtTagFilter = "tag:%s" | ||||||
tagKeyFilter = "tag-key" | ||||||
) | ||||||
|
||||||
var ( | ||||||
|
@@ -50,6 +51,17 @@ type Filter struct { | |||||
Values []string | ||||||
} | ||||||
|
||||||
// FilterForTags takes a key and optional values to construct an EC2 filter. | ||||||
func FilterForTags(key string, values ...string) Filter { | ||||||
if len(values) == 0 { | ||||||
return Filter{Name: tagKeyFilter, Values: []string{key}} | ||||||
} | ||||||
dannyrandall marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
return Filter{ | ||||||
Name: fmt.Sprintf(FmtTagFilter, key), | ||||||
Values: values, | ||||||
} | ||||||
} | ||||||
|
||||||
// EC2 wraps an AWS EC2 client. | ||||||
type EC2 struct { | ||||||
client api | ||||||
|
@@ -322,7 +334,6 @@ func (c *EC2) subnets(filters ...Filter) ([]*ec2.Subnet, error) { | |||||
return nil, fmt.Errorf("describe subnets: %w", err) | ||||||
} | ||||||
subnets = append(subnets, response.Subnets...) | ||||||
|
||||||
for response.NextToken != nil { | ||||||
response, err = c.client.DescribeSubnets(&ec2.DescribeSubnetsInput{ | ||||||
Filters: inputFilters, | ||||||
|
@@ -333,7 +344,9 @@ func (c *EC2) subnets(filters ...Filter) ([]*ec2.Subnet, error) { | |||||
} | ||||||
subnets = append(subnets, response.Subnets...) | ||||||
} | ||||||
|
||||||
if len(subnets) == 0 { | ||||||
return nil, fmt.Errorf("cannot find any subnets") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
return subnets, nil | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/ssm" | ||
"github.com/aws/copilot-cli/internal/pkg/describe" | ||
|
||
|
@@ -44,6 +45,7 @@ type deployJobOpts struct { | |
// cached variables | ||
targetApp *config.Application | ||
targetEnv *config.Environment | ||
envSess *session.Session | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😰 were we not using the correct session for job deploy this entire time>>> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is actually used here |
||
appliedManifest interface{} | ||
rootUserARN string | ||
} | ||
|
@@ -149,6 +151,7 @@ func (o *deployJobOpts) Execute() error { | |
interpolator: o.newInterpolator(o.appName, o.envName), | ||
ws: o.ws, | ||
unmarshal: o.unmarshal, | ||
sess: o.envSess, | ||
}) | ||
if err != nil { | ||
return err | ||
|
@@ -220,6 +223,11 @@ func (o *deployJobOpts) configureClients() error { | |
if err != nil { | ||
return fmt.Errorf("create default session: %w", err) | ||
} | ||
envSess, err := o.sessProvider.FromRole(env.ManagerRoleARN, env.Region) | ||
if err != nil { | ||
return err | ||
} | ||
o.envSess = envSess | ||
|
||
// client to retrieve caller identity. | ||
caller, err := identity.New(defaultSess).Get() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
//go:build localintegration | ||
// +build localintegration | ||
//go:build integration || localintegration | ||
|
||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
@@ -48,11 +47,11 @@ func TestGrpcLoadBalancedWebService_Template(t *testing.T) { | |
require.NoError(t, err) | ||
envMft, err := mft.ApplyEnv(tc.envName) | ||
require.NoError(t, err) | ||
|
||
err = envMft.Validate() | ||
require.NoError(t, err) | ||
content := envMft.Manifest() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you thing we also want to add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we add it it is not local anymore lol There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not local only if it has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like the only reason why these tests have all these Another way that I think about it is that I think these integration tests were meant to test that "given a manifest input, do I eventually get an expected template". Without calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's true. IMO we need to
|
||
|
||
v, ok := envMft.(*manifest.LoadBalancedWebService) | ||
v, ok := content.(*manifest.LoadBalancedWebService) | ||
require.True(t, ok) | ||
|
||
envConfig := &manifest.Environment{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is a really clean function signature 👍 😍