Repository: PrefectHQ/prefect

Issue:
Use better naming conventions for deployed tasks/jobs
## Current behavior
e.g. the Fargate agent creates tasks called `prefect-task` and the FargateTaskEnvironment created tasks called `prefect-task`. These should be better named



## Proposed behavior
Come up with better names for the intermediate tasks/jobs and those which actually run the flow




## Example
N/A


Discussion:

Resolving patch:
diff --git a/src/prefect/agent/fargate/agent.py b/src/prefect/agent/fargate/agent.py
--- a/src/prefect/agent/fargate/agent.py
+++ b/src/prefect/agent/fargate/agent.py
@@ -14,6 +14,13 @@ class FargateAgent(Agent):
     long as the proper access configuration variables are set.  Information on using the
     Fargate Agent can be found at https://docs.prefect.io/cloud/agent/fargate.html
 
+    All `kwargs` are accepted that one would normally pass to boto3 for `register_task_definition`
+    and `run_task`. For information on the kwargs supported visit the following links:
+
+    https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs.html#ECS.Client.register_task_definition
+
+    https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs.html#ECS.Client.run_task
+
     Args:
         - name (str, optional): An optional name to give this agent. Can also be set through
             the environment variable `PREFECT__CLOUD__AGENT__NAME`. Defaults to "agent"
@@ -28,112 +35,36 @@ class FargateAgent(Agent):
         - aws_session_token (str, optional): AWS session key for connecting the boto3
             client. Defaults to the value set in the environment variable
             `AWS_SESSION_TOKEN`.
-        - task_role_arn (str, optional): AWS Amazon Resource Name (ARN) of the AWS
-            Identity and Access Management (IAM) role that grants containers in the
-            task permission to call AWS APIs on your behalf. Defaults to the value set
-             in the environment variable `TASK_ROLE_ARN`.
-        - execution_role_arn (str, optional): AWS Amazon Resource Name (ARN) of the
-            task execution role that containers in this task can assume. Defaults to
-             the value set in the environment variable `EXECUTION_ROLE_ARN`.
         - region_name (str, optional): AWS region name for connecting the boto3 client.
             Defaults to the value set in the environment variable `REGION_NAME`.
-        - cluster (str, optional): The Fargate cluster to deploy tasks. Defaults to the
-            value set in the environment variable `CLUSTER`.
-        - subnets (list, optional): A list of AWS VPC subnets to use for the tasks that
-            are deployed on Fargate. Defaults to the value set in the environment
-            variable `SUBNETS`.
-        - security_groups (list, optional): A list of security groups to associate with
-            the deployed tasks. Defaults to the value set in the environment variable
-            `SECURITY_GROUPS`.
-        - repository_credentials (str, optional): An Amazon Resource Name (ARN) of the
-            secret containing the private repository credentials. Defaults to the value
-            set in the environment variable `REPOSITORY_CREDENTIALS`.
-        - assign_public_ip (str, optional): Whether the task's elastic network interface
-            receives a public IP address. Defaults to the value set in the environment
-            variable `ASSIGN_PUBLIC_IP` or `ENABLED` otherwise.
-        - task_cpu (str, optional): The number of cpu units reserved for the container.
-            Defaults to the value set in the environment variable `TASK_CPU` or `256`
-            otherwise.
-        - task_memory (str, optional): The hard limit (in MiB) of memory to present to
-            the container. Defaults to the value set in the environment variable
-            `TASK_MEMORY` or `512` otherwise.
+        - **kwargs (dict, optional): additional keyword arguments to pass to boto3 for
+            `register_task_definition` and `run_task`
     """
 
-    def __init__(
+    def __init__(  # type: ignore
         self,
         name: str = None,
         labels: Iterable[str] = None,
         aws_access_key_id: str = None,
         aws_secret_access_key: str = None,
         aws_session_token: str = None,
-        task_role_arn: str = None,
-        execution_role_arn: str = None,
         region_name: str = None,
-        cluster: str = None,
-        subnets: list = None,
-        security_groups: list = None,
-        repository_credentials: str = None,
-        assign_public_ip: str = None,
-        task_cpu: str = None,
-        task_memory: str = None,
+        **kwargs
     ) -> None:
         super().__init__(name=name, labels=labels)
 
         from boto3 import client as boto3_client
 
         # Config used for boto3 client initialization
-        aws_access_key_id = aws_access_key_id or os.getenv("AWS_ACCESS_KEY_ID")
+        aws_access_key_id = aws_access_key_id or os.getenv("AWS_ACCESS_KEY_ID", "")
         aws_secret_access_key = aws_secret_access_key or os.getenv(
-            "AWS_SECRET_ACCESS_KEY"
+            "AWS_SECRET_ACCESS_KEY", ""
         )
-        aws_session_token = aws_session_token or os.getenv("AWS_SESSION_TOKEN")
-        region_name = region_name or os.getenv("REGION_NAME")
+        aws_session_token = aws_session_token or os.getenv("AWS_SESSION_TOKEN", "")
+        region_name = region_name or os.getenv("REGION_NAME", "")
 
-        # Agent task config
-        self.task_role_arn = task_role_arn or os.getenv("TASK_ROLE_ARN", "")
-        self.logger.debug("Task role arn {}".format(self.task_role_arn))
-
-        self.execution_role_arn = execution_role_arn or os.getenv(
-            "EXECUTION_ROLE_ARN", ""
-        )
-        self.logger.debug("Execution role arn {}".format(self.execution_role_arn))
-
-        self.cluster = cluster or os.getenv("CLUSTER", "default")
-        self.logger.debug("Cluster {}".format(self.cluster))
-
-        if subnets:
-            self.subnets = subnets
-        elif os.getenv("SUBNETS"):
-            self.subnets = str(os.getenv("SUBNETS")).split(",")
-        else:
-            self.subnets = []
-        self.logger.debug("Subnets {}".format(self.subnets))
-
-        if security_groups:
-            self.security_groups = security_groups
-        elif os.getenv("SECURITY_GROUPS"):
-            self.security_groups = str(os.getenv("SECURITY_GROUPS")).split(",")
-        else:
-            self.security_groups = []
-        self.logger.debug("Security groups {}".format(self.security_groups))
-
-        self.repository_credentials = repository_credentials or os.getenv(
-            "REPOSITORY_CREDENTIALS"
-        )
-        self.logger.debug(
-            "Repository credentials {}".format(self.repository_credentials)
-        )
-
-        self.assign_public_ip = assign_public_ip or os.getenv(
-            "ASSIGN_PUBLIC_IP", "ENABLED"
-        )
-        self.logger.debug("Assign public IP {}".format(self.assign_public_ip))
-
-        self.task_cpu = task_cpu or os.getenv("TASK_CPU", "256")
-        self.logger.debug("Task CPU {}".format(self.task_cpu))
-
-        self.task_memory = task_memory or os.getenv("TASK_MEMORY", "512")
-        self.logger.debug("Task Memory {}".format(self.task_memory))
+        # Parse accepted kwargs for definition and run
+        self.task_definition_kwargs, self.task_run_kwargs = self._parse_kwargs(kwargs)
 
         # Client initialization
         self.boto3_client = boto3_client(
@@ -144,20 +75,70 @@ def __init__(
             region_name=region_name,
         )
 
-        # Look for default subnets with `MapPublicIpOnLaunch` disabled
-        if not self.subnets:
-            self.logger.debug("No subnets provided, finding defaults")
-            ec2 = boto3_client(
-                "ec2",
-                aws_access_key_id=aws_access_key_id,
-                aws_secret_access_key=aws_secret_access_key,
-                aws_session_token=aws_session_token,
-                region_name=region_name,
-            )
-            for subnet in ec2.describe_subnets()["Subnets"]:
-                if not subnet.get("MapPublicIpOnLaunch"):
-                    self.subnets.append(subnet.get("SubnetId"))
-                    self.logger.debug("Subnet {} found".format(subnet.get("SubnetId")))
+    def _parse_kwargs(self, user_kwargs: dict) -> tuple:
+        """
+        Parse the kwargs passed in and separate them out for `register_task_definition`
+        and `run_task`. This is required because boto3 does not allow extra kwargs
+        and if they are provided it will raise botocore.exceptions.ParamValidationError.
+
+        Args:
+            - user_kwargs (dict): The kwargs passed to the initialization of the environment
+
+        Returns:
+            tuple: a tuple of two dictionaries (task_definition_kwargs, task_run_kwargs)
+        """
+        definition_kwarg_list = [
+            "taskRoleArn",
+            "executionRoleArn",
+            "volumes",
+            "placementConstraints",
+            "cpu",
+            "memory",
+            "tags",
+            "pidMode",
+            "ipcMode",
+            "proxyConfiguration",
+            "inferenceAccelerators",
+        ]
+
+        run_kwarg_list = [
+            "cluster",
+            "count",
+            "startedBy",
+            "group",
+            "placementConstraints",
+            "placementStrategy",
+            "platformVersion",
+            "networkConfiguration",
+            "tags",
+            "enableECSManagedTags",
+            "propagateTags",
+        ]
+
+        task_definition_kwargs = {}
+        for key, item in user_kwargs.items():
+            if key in definition_kwarg_list:
+                task_definition_kwargs.update({key: item})
+                self.logger.debug("{} = {}".format(key, item))
+
+        task_run_kwargs = {}
+        for key, item in user_kwargs.items():
+            if key in run_kwarg_list:
+                task_run_kwargs.update({key: item})
+                self.logger.debug("{} = {}".format(key, item))
+
+        # Check environment if keys were not provided
+        for key in definition_kwarg_list:
+            if not task_definition_kwargs.get(key) and os.getenv(key):
+                task_definition_kwargs.update({key: os.getenv(key)})
+                self.logger.debug("{} from environment variable".format(key))
+
+        for key in run_kwarg_list:
+            if not task_run_kwargs.get(key) and os.getenv(key):
+                task_run_kwargs.update({key: os.getenv(key)})
+                self.logger.debug("{} from environment variable".format(key))
+
+        return task_definition_kwargs, task_run_kwargs
 
     def deploy_flows(self, flow_runs: list) -> None:
         """
@@ -192,7 +173,7 @@ def _verify_task_definition_exists(self, flow_run: GraphQLResult) -> bool:
         Check if a task definition already exists for the flow
 
         Args:
-            - flow_runs (list): A list of GraphQLResult flow run objects
+            - flow_run (GraphQLResult): A GraphQLResult representing a flow run object
 
         Returns:
             - bool: whether or not a preexisting task definition is found for this flow
@@ -254,13 +235,6 @@ def _create_task_definition(self, flow_run: GraphQLResult) -> None:
             }
         ]
 
-        # Assign repository credentials if they are specified
-        if self.repository_credentials:
-            self.logger.debug("Assigning repository credentials")
-            container_definitions[0]["repositoryCredentials"] = {
-                "credentialsParameter": self.repository_credentials
-            }
-
         # Register task definition
         self.logger.debug(
             "Registering task definition {}".format(
@@ -272,10 +246,7 @@ def _create_task_definition(self, flow_run: GraphQLResult) -> None:
             containerDefinitions=container_definitions,
             requiresCompatibilities=["FARGATE"],
             networkMode="awsvpc",
-            cpu=self.task_cpu,
-            memory=self.task_memory,
-            taskRoleArn=self.task_role_arn,
-            executionRoleArn=self.execution_role_arn,
+            **self.task_definition_kwargs
         )
 
     def _run_task(self, flow_run: GraphQLResult) -> None:
@@ -301,20 +272,6 @@ def _run_task(self, flow_run: GraphQLResult) -> None:
             }
         ]
 
-        network_configuration = {
-            "awsvpcConfiguration": {
-                "subnets": self.subnets,
-                "assignPublicIp": self.assign_public_ip,
-            }
-        }
-
-        # Asssign task security groups if they are specified
-        if self.security_groups:
-            self.logger.debug("Assigning security groups")
-            network_configuration["awsvpcConfiguration"][
-                "securityGroups"
-            ] = self.security_groups
-
         # Run task
         self.logger.debug(
             "Running task using task definition {}".format(
@@ -322,13 +279,12 @@ def _run_task(self, flow_run: GraphQLResult) -> None:
             )
         )
         self.boto3_client.run_task(
-            cluster=self.cluster,
             taskDefinition="prefect-task-{}".format(
                 flow_run.flow.id[:8]  # type: ignore
             ),
             overrides={"containerOverrides": container_overrides},
             launchType="FARGATE",
-            networkConfiguration=network_configuration,
+            **self.task_run_kwargs
         )
 
 
diff --git a/src/prefect/environments/execution/fargate/fargate_task.py b/src/prefect/environments/execution/fargate/fargate_task.py
--- a/src/prefect/environments/execution/fargate/fargate_task.py
+++ b/src/prefect/environments/execution/fargate/fargate_task.py
@@ -43,6 +43,8 @@ class FargateTaskEnvironment(Environment):
 
     https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs.html#ECS.Client.run_task
 
+    Note: You must provide `family` and `taskDefinition` with the same string so they match on run of the task.
+
     The secrets and kwargs that are provided at initialization time of this environment
     are not serialized and will only ever exist on this object.
 
@@ -204,10 +206,7 @@ def setup(self, storage: "Docker") -> None:  # type: ignore
                 "python -c 'from prefect.environments import FargateTaskEnvironment; FargateTaskEnvironment().run_flow()'",
             ]
 
-            boto3_c.register_task_definition(
-                family="prefect-task-{}-custom".format(flow_run_id[:8]),
-                **self.task_definition_kwargs
-            )
+            boto3_c.register_task_definition(**self.task_definition_kwargs)
 
     def execute(  # type: ignore
         self, storage: "Docker", flow_location: str, **kwargs: Any
@@ -249,7 +248,6 @@ def execute(  # type: ignore
         )
 
         boto3_c.run_task(
-            taskDefinition="prefect-task-{}-custom".format(flow_run_id[:8]),
             overrides={"containerOverrides": container_overrides},
             launchType="FARGATE",
             **self.task_run_kwargs


Test patch:
diff --git a/tests/agent/test_fargate_agent.py b/tests/agent/test_fargate_agent.py
--- a/tests/agent/test_fargate_agent.py
+++ b/tests/agent/test_fargate_agent.py
@@ -13,7 +13,7 @@
 from botocore.exceptions import ClientError
 
 
-def test_ecs_agent_init(monkeypatch, runner_token):
+def test_fargate_agent_init(monkeypatch, runner_token):
     boto3_client = MagicMock()
     monkeypatch.setattr("boto3.client", boto3_client)
 
@@ -22,7 +22,7 @@ def test_ecs_agent_init(monkeypatch, runner_token):
     assert agent.boto3_client
 
 
-def test_ecs_agent_config_options_default(monkeypatch, runner_token):
+def test_fargate_agent_config_options_default(monkeypatch, runner_token):
     boto3_client = MagicMock()
     monkeypatch.setattr("boto3.client", boto3_client)
 
@@ -30,15 +30,8 @@ def test_ecs_agent_config_options_default(monkeypatch, runner_token):
     assert agent
     assert agent.labels == []
     assert agent.name == "agent"
-    assert agent.cluster == "default"
-    assert not agent.subnets
-    assert not agent.security_groups
-    assert not agent.repository_credentials
-    assert agent.task_role_arn == ""
-    assert agent.execution_role_arn == ""
-    assert agent.assign_public_ip == "ENABLED"
-    assert agent.task_cpu == "256"
-    assert agent.task_memory == "512"
+    assert agent.task_definition_kwargs == {}
+    assert agent.task_run_kwargs == {}
     assert agent.boto3_client
 
 
@@ -56,37 +49,202 @@ def test_k8s_agent_config_options(monkeypatch, runner_token):
         assert agent.boto3_client
 
 
-def test_ecs_agent_config_options_init(monkeypatch, runner_token):
+def test_parse_task_definition_kwargs(monkeypatch, runner_token):
     boto3_client = MagicMock()
     monkeypatch.setattr("boto3.client", boto3_client)
 
+    agent = FargateAgent()
+
+    kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+    }
+
+    task_definition_kwargs, task_run_kwargs = agent._parse_kwargs(kwarg_dict)
+
+    assert task_definition_kwargs == kwarg_dict
+    assert task_run_kwargs == {"placementConstraints": "test", "tags": "test"}
+
+
+def test_parse_task_run_kwargs(monkeypatch, runner_token):
+    boto3_client = MagicMock()
+    monkeypatch.setattr("boto3.client", boto3_client)
+
+    agent = FargateAgent()
+
+    kwarg_dict = {
+        "cluster": "test",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementConstraints": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": "test",
+        "tags": "test",
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
+    task_definition_kwargs, task_run_kwargs = agent._parse_kwargs(kwarg_dict)
+
+    assert task_run_kwargs == kwarg_dict
+    assert task_definition_kwargs == {"placementConstraints": "test", "tags": "test"}
+
+
+def test_parse_task_definition_and_run_kwargs(monkeypatch, runner_token):
+    boto3_client = MagicMock()
+    monkeypatch.setattr("boto3.client", boto3_client)
+
+    agent = FargateAgent()
+
+    def_kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+    }
+
+    run_kwarg_dict = {
+        "cluster": "test",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementConstraints": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": "test",
+        "tags": "test",
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
+    kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+        "cluster": "test",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": "test",
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
+    task_definition_kwargs, task_run_kwargs = agent._parse_kwargs(kwarg_dict)
+
+    assert task_definition_kwargs == def_kwarg_dict
+    assert task_run_kwargs == run_kwarg_dict
+
+
+def test_parse_task_kwargs_invalid_value_removed(monkeypatch, runner_token):
+    boto3_client = MagicMock()
+    monkeypatch.setattr("boto3.client", boto3_client)
+
+    agent = FargateAgent()
+
+    kwarg_dict = {"test": "not_real"}
+
+    task_definition_kwargs, task_run_kwargs = agent._parse_kwargs(kwarg_dict)
+
+    assert task_definition_kwargs == {}
+    assert task_run_kwargs == {}
+
+
+def test_fargate_agent_config_options_init(monkeypatch, runner_token):
+    boto3_client = MagicMock()
+    monkeypatch.setattr("boto3.client", boto3_client)
+
+    def_kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+    }
+
+    run_kwarg_dict = {
+        "cluster": "test",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementConstraints": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": "test",
+        "tags": "test",
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
+    kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+        "cluster": "test",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": "test",
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
     agent = FargateAgent(
         name="test",
         aws_access_key_id="id",
         aws_secret_access_key="secret",
         aws_session_token="token",
-        task_role_arn="task_role_arn",
-        execution_role_arn="execution_role_arn",
         region_name="region",
-        cluster="cluster",
-        subnets=["subnet"],
-        security_groups=["security_group"],
-        repository_credentials="repo",
-        assign_public_ip="DISABLED",
-        task_cpu="1",
-        task_memory="2",
+        **kwarg_dict
     )
     assert agent
     assert agent.name == "test"
-    assert agent.task_role_arn == "task_role_arn"
-    assert agent.execution_role_arn == "execution_role_arn"
-    assert agent.cluster == "cluster"
-    assert agent.subnets == ["subnet"]
-    assert agent.security_groups == ["security_group"]
-    assert agent.repository_credentials == "repo"
-    assert agent.assign_public_ip == "DISABLED"
-    assert agent.task_cpu == "1"
-    assert agent.task_memory == "2"
+    assert agent.task_definition_kwargs == def_kwarg_dict
+    assert agent.task_run_kwargs == run_kwarg_dict
 
     boto3_client.assert_called_with(
         "ecs",
@@ -97,31 +255,70 @@ def test_ecs_agent_config_options_init(monkeypatch, runner_token):
     )
 
 
-def test_ecs_agent_config_env_vars(monkeypatch, runner_token):
+def test_fargate_agent_config_env_vars(monkeypatch, runner_token):
     boto3_client = MagicMock()
     monkeypatch.setattr("boto3.client", boto3_client)
 
+    def_kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+    }
+
+    run_kwarg_dict = {
+        "cluster": "test",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementConstraints": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": "test",
+        "tags": "test",
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
+    # Client args
     monkeypatch.setenv("AWS_ACCESS_KEY_ID", "id")
     monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret")
     monkeypatch.setenv("AWS_SESSION_TOKEN", "token")
-    monkeypatch.setenv("TASK_ROLE_ARN", "task_role_arn")
-    monkeypatch.setenv("EXECUTION_ROLE_ARN", "execution_role_arn")
     monkeypatch.setenv("REGION_NAME", "region")
-    monkeypatch.setenv("CLUSTER", "cluster")
-    monkeypatch.setenv("REPOSITORY_CREDENTIALS", "repo")
-    monkeypatch.setenv("ASSIGN_PUBLIC_IP", "DISABLED")
-    monkeypatch.setenv("TASK_CPU", "1")
-    monkeypatch.setenv("TASK_MEMORY", "2")
+
+    # Def / run args
+    monkeypatch.setenv("taskRoleArn", "test")
+    monkeypatch.setenv("executionRoleArn", "test")
+    monkeypatch.setenv("volumes", "test")
+    monkeypatch.setenv("placementConstraints", "test")
+    monkeypatch.setenv("cpu", "test")
+    monkeypatch.setenv("memory", "test")
+    monkeypatch.setenv("tags", "test")
+    monkeypatch.setenv("pidMode", "test")
+    monkeypatch.setenv("ipcMode", "test")
+    monkeypatch.setenv("proxyConfiguration", "test")
+    monkeypatch.setenv("inferenceAccelerators", "test")
+    monkeypatch.setenv("cluster", "test")
+    monkeypatch.setenv("count", "test")
+    monkeypatch.setenv("startedBy", "test")
+    monkeypatch.setenv("group", "test")
+    monkeypatch.setenv("placementStrategy", "test")
+    monkeypatch.setenv("platformVersion", "test")
+    monkeypatch.setenv("networkConfiguration", "test")
+    monkeypatch.setenv("enableECSManagedTags", "test")
+    monkeypatch.setenv("propagateTags", "test")
 
     agent = FargateAgent(subnets=["subnet"])
     assert agent
-    assert agent.execution_role_arn == "execution_role_arn"
-    assert agent.task_role_arn == "task_role_arn"
-    assert agent.cluster == "cluster"
-    assert agent.repository_credentials == "repo"
-    assert agent.assign_public_ip == "DISABLED"
-    assert agent.task_cpu == "1"
-    assert agent.task_memory == "2"
+    assert agent.task_definition_kwargs == def_kwarg_dict
+    assert agent.task_run_kwargs == run_kwarg_dict
 
     boto3_client.assert_called_with(
         "ecs",
@@ -132,20 +329,6 @@ def test_ecs_agent_config_env_vars(monkeypatch, runner_token):
     )
 
 
-def test_default_subnets(monkeypatch, runner_token):
-    boto3_client = MagicMock()
-    boto3_client.describe_subnets.return_value = {
-        "Subnets": [
-            {"MapPublicIpOnLaunch": False, "SubnetId": "id"},
-            {"MapPublicIpOnLaunch": True, "SubnetId": "id2"},
-        ]
-    }
-    monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3_client))
-
-    agent = FargateAgent()
-    assert agent.subnets == ["id"]
-
-
 def test_deploy_flows(monkeypatch, runner_token):
     boto3_client = MagicMock()
 
@@ -175,7 +358,6 @@ def test_deploy_flows(monkeypatch, runner_token):
 
     assert boto3_client.describe_task_definition.called
     assert boto3_client.run_task.called
-    assert boto3_client.run_task.call_args[1]["cluster"] == "default"
 
 
 def test_deploy_flows_all_args(monkeypatch, runner_token):
@@ -186,20 +368,41 @@ def test_deploy_flows_all_args(monkeypatch, runner_token):
 
     monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3_client))
 
+    kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "test",
+        "memory": "test",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+        "cluster": "cluster",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": {
+            "awsvpcConfiguration": {
+                "subnets": ["subnet"],
+                "assignPublicIp": "DISABLED",
+                "securityGroups": ["security_group"],
+            }
+        },
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
     agent = FargateAgent(
         aws_access_key_id="id",
         aws_secret_access_key="secret",
         aws_session_token="token",
-        task_role_arn="task_role_arn",
-        execution_role_arn="execution_role_arn",
         region_name="region",
-        cluster="cluster",
-        subnets=["subnet"],
-        security_groups=["security_group"],
-        repository_credentials="repo",
-        assign_public_ip="DISABLED",
-        task_cpu="1",
-        task_memory="2",
+        **kwarg_dict
     )
     agent.deploy_flows(
         flow_runs=[
@@ -244,41 +447,6 @@ def test_deploy_flows_all_args(monkeypatch, runner_token):
     }
 
 
-def test_deploy_flows_no_security_group(monkeypatch, runner_token):
-    boto3_client = MagicMock()
-
-    boto3_client.describe_task_definition.return_value = {}
-    boto3_client.run_task.return_value = {}
-
-    monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3_client))
-
-    agent = FargateAgent()
-    agent.deploy_flows(
-        flow_runs=[
-            GraphQLResult(
-                {
-                    "flow": GraphQLResult(
-                        {
-                            "storage": Docker(
-                                registry_url="test", image_name="name", image_tag="tag"
-                            ).serialize(),
-                            "id": "id",
-                        }
-                    ),
-                    "id": "id",
-                }
-            )
-        ]
-    )
-
-    assert boto3_client.describe_task_definition.called
-    assert boto3_client.run_task.called
-    assert boto3_client.run_task.call_args[1]["cluster"] == "default"
-    assert boto3_client.run_task.call_args[1]["networkConfiguration"] == {
-        "awsvpcConfiguration": {"subnets": [], "assignPublicIp": "ENABLED"}
-    }
-
-
 def test_deploy_flows_register_task_definition(monkeypatch, runner_token):
     boto3_client = MagicMock()
 
@@ -324,20 +492,41 @@ def test_deploy_flows_register_task_definition_all_args(monkeypatch, runner_toke
 
     monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3_client))
 
+    kwarg_dict = {
+        "taskRoleArn": "test",
+        "executionRoleArn": "test",
+        "volumes": "test",
+        "placementConstraints": "test",
+        "cpu": "1",
+        "memory": "2",
+        "tags": "test",
+        "pidMode": "test",
+        "ipcMode": "test",
+        "proxyConfiguration": "test",
+        "inferenceAccelerators": "test",
+        "cluster": "cluster",
+        "count": "test",
+        "startedBy": "test",
+        "group": "test",
+        "placementStrategy": "test",
+        "platformVersion": "test",
+        "networkConfiguration": {
+            "awsvpcConfiguration": {
+                "subnets": ["subnet"],
+                "assignPublicIp": "DISABLED",
+                "securityGroups": ["security_group"],
+            }
+        },
+        "enableECSManagedTags": "test",
+        "propagateTags": "test",
+    }
+
     agent = FargateAgent(
         aws_access_key_id="id",
         aws_secret_access_key="secret",
         aws_session_token="token",
-        task_role_arn="task_role_arn",
-        execution_role_arn="execution_role_arn",
         region_name="region",
-        cluster="cluster",
-        subnets=["subnet"],
-        security_groups=["security_group"],
-        repository_credentials="repo",
-        assign_public_ip="DISABLED",
-        task_cpu="1",
-        task_memory="2",
+        **kwarg_dict
     )
     agent.deploy_flows(
         flow_runs=[
@@ -385,7 +574,6 @@ def test_deploy_flows_register_task_definition_all_args(monkeypatch, runner_toke
                 },
             ],
             "essential": True,
-            "repositoryCredentials": {"credentialsParameter": "repo"},
         }
     ]
     assert boto3_client.register_task_definition.call_args[1][
diff --git a/tests/environments/execution/test_fargate_task_environment.py b/tests/environments/execution/test_fargate_task_environment.py
--- a/tests/environments/execution/test_fargate_task_environment.py
+++ b/tests/environments/execution/test_fargate_task_environment.py
@@ -221,6 +221,7 @@ def test_setup_definition_register(monkeypatch):
     monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3_client))
 
     environment = FargateTaskEnvironment(
+        family="test",
         containerDefinitions=[
             {
                 "name": "flow",
@@ -229,17 +230,14 @@ def test_setup_definition_register(monkeypatch):
                 "environment": [],
                 "essential": True,
             }
-        ]
+        ],
     )
 
     environment.setup(Docker(registry_url="test", image_name="image", image_tag="tag"))
 
     assert boto3_client.describe_task_definition.called
     assert boto3_client.register_task_definition.called
-    assert (
-        boto3_client.register_task_definition.call_args[1]["family"]
-        == "prefect-task-unknown-custom"
-    )
+    assert boto3_client.register_task_definition.call_args[1]["family"] == "test"
     assert boto3_client.register_task_definition.call_args[1][
         "containerDefinitions"
     ] == [
@@ -277,7 +275,9 @@ def test_execute_run_task(monkeypatch):
     boto3_client.run_task.return_value = {}
     monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3_client))
 
-    environment = FargateTaskEnvironment(cluster="test")
+    environment = FargateTaskEnvironment(
+        cluster="test", family="test", taskDefinition="test"
+    )
 
     environment.execute(
         storage=Docker(registry_url="test", image_name="image", image_tag="tag"),
@@ -285,10 +285,7 @@ def test_execute_run_task(monkeypatch):
     )
 
     assert boto3_client.run_task.called
-    assert (
-        boto3_client.run_task.call_args[1]["taskDefinition"]
-        == "prefect-task-unknown-custom"
-    )
+    assert boto3_client.run_task.call_args[1]["taskDefinition"] == "test"
     assert boto3_client.run_task.call_args[1]["overrides"] == {
         "containerOverrides": [
             {
@@ -400,6 +397,8 @@ def test_entire_environment_process_together(monkeypatch):
                 }
             ],
             cluster="test",
+            family="test",
+            taskDefinition="test",
         )
 
         assert environment
@@ -411,10 +410,7 @@ def test_entire_environment_process_together(monkeypatch):
 
         assert boto3_client.describe_task_definition.called
         assert boto3_client.register_task_definition.called
-        assert (
-            boto3_client.register_task_definition.call_args[1]["family"]
-            == "prefect-task-id-custom"
-        )
+        assert boto3_client.register_task_definition.call_args[1]["family"] == "test"
         assert boto3_client.register_task_definition.call_args[1][
             "containerDefinitions"
         ] == [
@@ -449,10 +445,7 @@ def test_entire_environment_process_together(monkeypatch):
         environment.execute(storage=storage, flow_location=".prefect/flows")
 
         assert boto3_client.run_task.called
-        assert (
-            boto3_client.run_task.call_args[1]["taskDefinition"]
-            == "prefect-task-id-custom"
-        )
+        assert boto3_client.run_task.call_args[1]["taskDefinition"] == "test"
         assert boto3_client.run_task.call_args[1]["overrides"] == {
             "containerOverrides": [
                 {