Skip to content

Commit df28d9b

Browse files
committed
Add WithInternetAccess() opt-in and fix default override ordering
Add ec2.WithInternetAccess() VMOption as the explicit opt-in counterpart to WithoutInternetAccess(). Provisioners that default to no-internet now prepend the default option (instead of appending it) so that caller-provided ec2.WithInternetAccess() can override it. Tests that need to reach external hosts must now explicitly pass ec2.WithInternetAccess() via their provisioner options.
1 parent 5b0ef8c commit df28d9b

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

  • test/e2e-framework

test/e2e-framework/scenarios/aws/ec2/vmargs.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,14 @@ func WithoutInternetAccess() VMOption {
161161
return nil
162162
}
163163
}
164+
165+
// WithInternetAccess explicitly opts the VM into internet access, overriding any
166+
// no-internet default set by the provisioner. Tests that need to reach external
167+
// hosts (e.g. to download packages, pull images, or contact external APIs) must
168+
// call this option explicitly.
169+
func WithInternetAccess() VMOption {
170+
return func(p *vmArgs) error {
171+
p.withoutInternetAccess = false
172+
return nil
173+
}
174+
}

test/e2e-framework/testing/provisioners/aws/host/host.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ func Provisioner(opts ...ProvisionerOption) provisioners.TypedProvisioner[enviro
7474
provisioner := provisioners.NewTypedPulumiProvisioner(provisionerBaseID+runParams.Name, func(ctx *pulumi.Context, env *environments.Host) error {
7575
// We ALWAYS need to make a deep copy of `params`, as the provisioner can be called multiple times.
7676
// and it's easy to forget about it, leading to hard to debug issues.
77-
opts = append(opts, WithRunOptions(ec2.WithEC2InstanceOptions(ec2.WithoutInternetAccess())))
77+
// Prepend the no-internet default so that caller-provided opts (e.g. ec2.WithInternetAccess()) can override it.
78+
opts = append([]ProvisionerOption{WithRunOptions(ec2.WithEC2InstanceOptions(ec2.WithoutInternetAccess()))}, opts...)
7879
params := getProvisionerParams(opts...)
7980
runParams := ec2.GetParams(params.runOptions...)
8081

0 commit comments

Comments
 (0)