<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I try to access a python file contains ArcPy functions from AWS lambda to EC2 Instance. in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335733#M73774</link>
    <description>&lt;P&gt;ArcGIS pro accessible and licensed on EC2. Also with the same ArcGIS Pro cloned python environment working fine on EC2. there are no error when i run ArcPy related scripts on EC2. On other hand if i run the scripts with lambda function trigger, its throwing an error called&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from ._arcgisscripting import *\r\nRuntimeError: The Product License has not been initialized.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2023 12:34:38 GMT</pubDate>
    <dc:creator>SangeethAmirthanathan</dc:creator>
    <dc:date>2023-10-06T12:34:38Z</dc:date>
    <item>
      <title>I try to access a python file contains ArcPy functions from AWS lambda to EC2 Instance.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335424#M73737</link>
      <description>&lt;P&gt;I have a lambda trigger that will execute when i put the FGDB to S3 bucket. this lambda trigger to an EC2 instance python file contains ArcPy functionalities. I am getting an error below&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;" from ._arcgisscripting import *\r\nRuntimeError: The Product License has not been initialized."&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here is the lambda fucntion&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import time
import json
import boto3

def lambda_handler(event, context):
    # boto3 client
    client = boto3.client("ec2")
    ssm = boto3.client("ssm", region_name='us-west-2')

    # getting instance information
    describeInstance = client.describe_instances()

    InstanceId = "i-xxxxxxxxxxxx"

    # Check if the Lambda was triggered by an S3 event
    if 'Records' in event and len(event['Records']) &amp;gt; 0:
        s3_event = event['Records'][0]['s3']
        bucket_name = s3_event['bucket']['name']
        object_key = s3_event['object']['key']

        # Construct the S3 file path
        s3_file_path = f"s3://{bucket_name}/{object_key}"
        
        

        # command to be executed on instance
        response = ssm.send_command(InstanceIds=[InstanceId], DocumentName="AWS-RunPowerShellScript",
                                    Parameters={
                                        "commands": [
                                            f"C:\\Users\\Administrator\\AppData\\Local\\ESRI\\conda\\envs\\arcgispro-py3-clone-1\\python.exe C:\\Users\\Administrator\\Desktop\\Automation\\DownloadZIP.py {s3_file_path}"
                                        ]
                                    })
    
        # fetching command id for the output
        command_id = response["Command"]["CommandId"]
    
        time.sleep(30)
    
        # fetching command output
        output = ssm.get_command_invocation(CommandId=command_id, InstanceId=InstanceId)
        print(output)
    
        return {"statusCode": 200, "body": json.dumps("Run Successful")}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting an error when only EC2 instance contains ArcPy functionalities otherwise if I am not getting any error. functions are working fine.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Error&lt;BR /&gt;&lt;BR /&gt;" from ._arcgisscripting import *\r\nRuntimeError: The Product License has not been initialized."&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 15:41:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335424#M73737</guid>
      <dc:creator>SangeethAmirthanathan</dc:creator>
      <dc:date>2023-10-05T15:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: I try to access a python file contains ArcPy functions from AWS lambda to EC2 Instance.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335599#M73758</link>
      <description>&lt;P&gt;Is ArcGIS Pro accessible and licensed to the user that is running the powershell script to invoke the py file?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 21:11:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335599#M73758</guid>
      <dc:creator>AnthonyRyanEQL</dc:creator>
      <dc:date>2023-10-05T21:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: I try to access a python file contains ArcPy functions from AWS lambda to EC2 Instance.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335733#M73774</link>
      <description>&lt;P&gt;ArcGIS pro accessible and licensed on EC2. Also with the same ArcGIS Pro cloned python environment working fine on EC2. there are no error when i run ArcPy related scripts on EC2. On other hand if i run the scripts with lambda function trigger, its throwing an error called&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from ._arcgisscripting import *\r\nRuntimeError: The Product License has not been initialized.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 12:34:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/i-try-to-access-a-python-file-contains-arcpy/m-p/1335733#M73774</guid>
      <dc:creator>SangeethAmirthanathan</dc:creator>
      <dc:date>2023-10-06T12:34:38Z</dc:date>
    </item>
  </channel>
</rss>

