-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 'aws_ec2_client_vpn_endpoint.tags' attribute #7619
Changes from 1 commit
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 |
---|---|---|
|
@@ -108,6 +108,7 @@ func resourceAwsEc2ClientVpnEndpoint() *schema.Resource { | |
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"tags": tagsSchema(), | ||
}, | ||
} | ||
} | ||
|
@@ -119,6 +120,7 @@ func resourceAwsEc2ClientVpnEndpointCreate(d *schema.ResourceData, meta interfac | |
ClientCidrBlock: aws.String(d.Get("client_cidr_block").(string)), | ||
ServerCertificateArn: aws.String(d.Get("server_certificate_arn").(string)), | ||
TransportProtocol: aws.String(d.Get("transport_protocol").(string)), | ||
TagSpecifications: tagSpecificationsFromMap(d.Get("tags").(map[string]interface{}), ec2.ResourceTypeClientVpnEndpoint), | ||
} | ||
|
||
if v, ok := d.GetOk("description"); ok { | ||
|
@@ -235,6 +237,11 @@ func resourceAwsEc2ClientVpnEndpointRead(d *schema.ResourceData, meta interface{ | |
return err | ||
} | ||
|
||
err = d.Set("tags", tagsToMap(result.ClientVpnEndpoints[0].Tags)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -254,6 +261,8 @@ func resourceAwsEc2ClientVpnEndpointDelete(d *schema.ResourceData, meta interfac | |
func resourceAwsEc2ClientVpnEndpointUpdate(d *schema.ResourceData, meta interface{}) error { | ||
conn := meta.(*AWSClient).ec2conn | ||
|
||
d.Partial(true) | ||
|
||
req := &ec2.ModifyClientVpnEndpointInput{ | ||
ClientVpnEndpointId: aws.String(d.Id()), | ||
} | ||
|
@@ -304,11 +313,17 @@ func resourceAwsEc2ClientVpnEndpointUpdate(d *schema.ResourceData, meta interfac | |
} | ||
} | ||
|
||
_, err := conn.ModifyClientVpnEndpoint(req) | ||
if err != nil { | ||
if _, err := conn.ModifyClientVpnEndpoint(req); err != nil { | ||
return fmt.Errorf("Error modifying Client VPN endpoint: %s", err) | ||
} | ||
|
||
if err := setTags(conn, d); err != nil { | ||
return err | ||
} else { | ||
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. Since the previous conditional calls |
||
d.SetPartial("tags") | ||
} | ||
|
||
d.Partial(false) | ||
return resourceAwsEc2ClientVpnEndpointRead(d, meta) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -476,3 +476,17 @@ func tagsMapToRaw(m map[string]string) map[string]interface{} { | |
|
||
return raw | ||
} | ||
|
||
// tagSpecificationsFromMap returns the tag specifications for the given map of data and resource type. | ||
func tagSpecificationsFromMap(m map[string]interface{}, t string) []*ec2.TagSpecification { | ||
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. Since the Go package structure is currently flat across all services, this should include ec2 in the function naming. I'd also recommend clarifying what the input parameters are for Go code tooling. func ec2TagSpecificationsFromMap(tags map[string]interface{}, resourceType string) []*ec2.TagSpecification { |
||
if len(m) == 0 { | ||
return nil | ||
} | ||
|
||
return []*ec2.TagSpecification{ | ||
{ | ||
ResourceType: aws.String(t), | ||
Tags: tagsFromMap(m), | ||
}, | ||
} | ||
} |
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.
We should return error context here for operators and code maintainers, e.g.
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.
I'll also add error context to the previous 2 calls to
d.Set()
forauthentication_options
andconnection_log_options
.