Task name: Day 30: Enable Internet Access for Private EC2 using NAT Instance
ID: https://engineer.kodekloud.com/task?id=691b2fa602362aa9a9f61495&status=start
Proof of completion
Error message
Full error message
No worries!!
Uh oh! Looks like the task was not completed successfully. But it's Ok. You can try again next time this task is assigned to you.
============================= test session starts ==============================
platform linux -- Python 3.10.17, pytest-8.3.5, pluggy-1.6.0
rootdir: /usr/share
plugins: testinfra-10.2.2
collected 1 item
../usr/share/test.py F [100%]
=================================== FAILURES ===================================
___________________________ test_nat_instance_setup ____________________________
def test_nat_instance_setup():
ec2 = boto3.client('ec2', region_name='us-east-1')
s3 = boto3.client('s3')
# Check NAT Instance exists
nat_instances = ec2.describe_instances(Filters=[
{'Name': 'tag:Name', 'Values': ['nautilus-nat-instance']}
])
assert nat_instances['Reservations'], "NAT Instance not found."
nat_instance_id = nat_instances['Reservations'][0]['Instances'][0]['InstanceId']
assert nat_instance_id, "Could not retrieve NAT Instance ID."
# Check source/dest check is disabled
> attr = ec2.describe_instance_attribute(InstanceId=nat_instance_id, Attribute='sourceDestCheck')
/usr/share/test.py:19:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.10/site-packages/botocore/client.py:595: in _api_call
return self._make_api_call(operation_name, kwargs)
/usr/local/lib/python3.10/site-packages/botocore/context.py:123: in wrapper
return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <botocore.client.EC2 object at 0x709705410e50>
operation_name = 'DescribeInstanceAttribute'
api_params = {'Attribute': 'sourceDestCheck', 'InstanceId': 'i-0e4f98ef45048c616'}
@with_current_context()
def _make_api_call(self, operation_name, api_params):
operation_model = self._service_model.operation_model(operation_name)
service_name = self._service_model.service_name
history_recorder.record(
'API_CALL',
{
'service': service_name,
'operation': operation_name,
'params': api_params,
},
)
if operation_model.deprecated:
logger.debug(
'Warning: %s.%s() is deprecated', service_name, operation_name
)
request_context = {
'client_region': self.meta.region_name,
'client_config': self.meta.config,
'has_streaming_input': operation_model.has_streaming_input,
'auth_type': operation_model.resolved_auth_type,
'unsigned_payload': operation_model.unsigned_payload,
}
api_params = self._emit_api_params(
api_params=api_params,
operation_model=operation_model,
context=request_context,
)
(
endpoint_url,
additional_headers,
properties,
) = self._resolve_endpoint_ruleset(
operation_model, api_params, request_context
)
if properties:
# Pass arbitrary endpoint info with the Request
# for use during construction.
request_context['endpoint_properties'] = properties
request_dict = self._convert_to_request_dict(
api_params=api_params,
operation_model=operation_model,
endpoint_url=endpoint_url,
context=request_context,
headers=additional_headers,
)
resolve_checksum_context(request_dict, operation_model, api_params)
service_id = self._service_model.service_id.hyphenize()
handler, event_response = self.meta.events.emit_until_response(
f'before-call.{service_id}.{operation_name}',
model=operation_model,
params=request_dict,
request_signer=self._request_signer,
context=request_context,
)
if event_response is not None:
http, parsed_response = event_response
else:
maybe_compress_request(
self.meta.config, request_dict, operation_model
)
apply_request_checksum(request_dict)
http, parsed_response = self._make_request(
operation_model, request_dict, request_context
)
self.meta.events.emit(
f'after-call.{service_id}.{operation_name}',
http_response=http,
parsed=parsed_response,
model=operation_model,
context=request_context,
)
if http.status_code >= 300:
error_info = parsed_response.get("Error", {})
error_code = error_info.get("QueryErrorCode") or error_info.get(
"Code"
)
error_class = self.exceptions.from_code(error_code)
> raise error_class(parsed_response, operation_name)
E botocore.exceptions.ClientError: An error occurred (InvalidParameterCombination) when calling the DescribeInstanceAttribute operation: You may only describe the sourceDestCheck attribute for VPC instances
/usr/local/lib/python3.10/site-packages/botocore/client.py:1058: ClientError
=========================== short test summary info ============================
FAILED ../usr/share/test.py::test_nat_instance_setup - botocore.exceptions.Cl...
============================== 1 failed in 1.27s ===============================
You may check your work again to see what went wrong. The environment expires in 5 minutes.
If you think you did your work correctly and is marked failed, you may request for a review from your task dashboard. Or alternatively please submit outputs/screenshot(s) of your work and post to community.kodekloud.com
You can also view your results in your dashboard under the "Active Practice" page.

