fix proxy and tls
This commit is contained in:
parent
3dc1dafe58
commit
ca9a5daf29
|
@ -14,7 +14,6 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||||
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
||||||
commonhelper "github.com/hashicorp/packer/helper/common"
|
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
vaultapi "github.com/hashicorp/vault/api"
|
vaultapi "github.com/hashicorp/vault/api"
|
||||||
)
|
)
|
||||||
|
@ -72,13 +71,14 @@ func (c *AccessConfig) Session() (*session.Session, error) {
|
||||||
config = config.WithEndpoint(c.CustomEndpointEc2)
|
config = config.WithEndpoint(c.CustomEndpointEc2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config = config.WithHTTPClient(cleanhttp.DefaultClient())
|
||||||
|
transport := config.HTTPClient.Transport.(*http.Transport)
|
||||||
if c.InsecureSkipTLSVerify {
|
if c.InsecureSkipTLSVerify {
|
||||||
config := config.WithHTTPClient(cleanhttp.DefaultClient())
|
|
||||||
transport := config.HTTPClient.Transport.(*http.Transport)
|
|
||||||
transport.TLSClientConfig = &tls.Config{
|
transport.TLSClientConfig = &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
transport.Proxy = http.ProxyFromEnvironment
|
||||||
|
|
||||||
opts := session.Options{
|
opts := session.Options{
|
||||||
SharedConfigState: session.SharedConfigEnable,
|
SharedConfigState: session.SharedConfigEnable,
|
||||||
|
@ -210,9 +210,7 @@ func (c *AccessConfig) NewEC2Connection() (ec2iface.EC2API, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ec2conn := ec2.New(sess, &aws.Config{
|
ec2conn := ec2.New(sess)
|
||||||
HTTPClient: commonhelper.HttpClientWithEnvironmentProxy(),
|
|
||||||
})
|
|
||||||
|
|
||||||
return ec2conn, nil
|
return ec2conn, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue