14 Feb 2023
	
		
		03:18 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		02 May 2023
	
		
		02:42 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			educampver
		
		
		
		
		
		
		
		
	
			
		
Hi everyone!
I created an app function when triggered should create a new firewall.
import { CreateFirewallCommand, NetworkFirewallClient } from '@aws-sdk/client-network-firewall';
export default async () => {
  const clientConfig = {
    region: 'us-east-1',
    credentials: {
      accessKeyId: '',
      secretAccessKey: '',
    },
  };
  const networkFirewallClient = new NetworkFirewallClient(clientConfig);
  const params = {
    FirewallName: 'VPC Firewall 2',
    // eslint-disable-next-line no-secrets/no-secrets
    FirewallPolicyArn: 'arnnetwork-firewall:us-east-1:123456789012:firewall-policy/my-policy',
    VpcId: 'vpc-0af6340303f3168d3',
    SubnetMappings: [{ SubnetId: 'subnet-005fedf40f2e91595', Tier: 'PUBLIC' }],
  };
  try {
    const command = new CreateFirewallCommand(params);
    const response = await networkFirewallClient.send(command);
    console.log('Firewall successfully created:', response.Firewall.FirewallId);
    return response;
  } catch (err) {
    console.error('An error occurred:', err);
    throw err;
  }
};
The problem is that I am not able to make any successful request because AWS rejects it because it was already send. I got this error code back:
I am not sure now if this is a problem within the server.js file or if the problem is somewhere else? Do you have any suggestions?
Cheers
Markus
Solved! Go to Solution.
15 Feb 2023 08:22 AM
For better seachability I add the error code in text form:
[ERROR] /api/aws-firewall Fehler beim Erstellen der Firewall: Error: AWS SDK error wrapper for TypeError: Cannot construct a Request with a Request object that has already been used.
    at asSdkError (C:\Users\markus.hobisch\IdeaProjects\dynatrace-cpa\api\aws-firewall.js:5133:10)
    at C:\Users\markus.hobisch\IdeaProjects\dynatrace-cpa\api\aws-firewall.js:5182:21
    at async C:\Users\markus.hobisch\IdeaProjects\dynatrace-cpa\api\aws-firewall.js:4726:20
    at async Module.aws_firewall_default (C:\Users\markus.hobisch\IdeaProjects\dynatrace-cpa\api\aws-firewall.js:7144:22)
    at async Socket.<anonymous> (C:\Users\markus.hobisch\IdeaProjects\dynatrace-cpa\node_modules\@dynatrace\runtime-simulator\lib\server.js:395:53) {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		15 Feb 2023 08:27 AM
Hi Markus,
I can reproduce the issue. The internal error is following:
Exception has occurred: TypeError: Cannot construct a Request with a Request object that has already been used.
at new Request (/node_modules/undici/lib/fetch/request.js:482:15)
at fetch (/node_modules/undici/lib/fetch/index.js:137:21)
at fetch (/node_modules/undici/index.js:111:20)
at /node_modules/@dynatrace/runtime-simulator/lib/server.js:1:3560
We are further looking into the issue and will keep you posted.
15 Feb 2023 02:59 PM
Did you try your Code with Node.js or a similar platform? Can you ensure that the problem lies within the execution via the Dynatrace Serverless Platform and not with the usage of the API?
15 Feb 2023 03:48 PM
Hi Stefan,
did not try it out on Node.js so far but I can and would let you know.
15 Feb 2023 04:32 PM
It works on Node.js. At least I get a different error (InvalidRequestException: Resource name has an invalid format) but this is fine because I didn't checked the format so far.
			
    
	
		
		
		15 Feb 2023
	
		
		04:43 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		16 Feb 2023
	
		
		08:17 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			stefan_eggersto
		
		
		
		
		
		
		
		
	
			
		
I also tried with the latest Deno installation and Chrome, and I'm also getting a different error. The error comes from calling `fetch` twice, and this looks like either a bundling issue or an execution issue on the runtime side.
15 Feb 2023 06:03 PM
We identified the issue, and it's a bug in the simulator. This error should not appear once the function is deployed.
16 Feb 2023 07:46 AM
Thanks for the update!